From 8418c014f52ce99651507fd80ccafdefa5c6c7a3 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Thu, 29 Oct 2020 19:55:05 +0000 Subject: [PATCH 1/5] [Path] Add TurnPart selection --- src/Mod/Path/PathScripts/PathSelection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index 1263f95cb3..d606def212 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -384,6 +384,7 @@ def select(op): opsel['Custom'] = customselect opsel['TurnFace'] = turnselect opsel['TurnProfile'] = turnselect + opsel['TurnPart'] = turnselect return opsel[op] From 4ea4ad84cedca9b6c50c163c28b473eb6137124d Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Thu, 29 Oct 2020 19:55:45 +0000 Subject: [PATCH 2/5] [Path] PEP8 Formatting fixes --- src/Mod/Path/PathScripts/PathSelection.py | 64 ++++++++++++----------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index d606def212..02406ae5ea 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -39,19 +39,20 @@ class PathBaseGate(object): class EGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument return sub and sub[0:4] == 'Edge' class MESHGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument return obj.TypeId[0:4] == 'Mesh' + class VCARVEGate: def allow(self, doc, obj, sub): try: shape = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0: @@ -77,10 +78,10 @@ class VCARVEGate: class ENGRAVEGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument try: shape = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0: @@ -98,10 +99,10 @@ class ENGRAVEGate(PathBaseGate): class CHAMFERGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument try: shape = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0: @@ -110,23 +111,21 @@ class CHAMFERGate(PathBaseGate): if shape.ShapeType == 'Edge': return True - if (shape.ShapeType == 'Face' - and shape.normalAt(0,0) == FreeCAD.Vector(0,0,1)): - return True + if (shape.ShapeType == 'Face' and shape.normalAt(0, 0) == FreeCAD.Vector(0, 0, 1)): + return True if sub: subShape = shape.getElement(sub) if subShape.ShapeType == 'Edge': return True - elif (subShape.ShapeType == 'Face' - and subShape.normalAt(0,0) == FreeCAD.Vector(0,0,1)): + elif (subShape.ShapeType == 'Face' and subShape.normalAt(0, 0) == FreeCAD.Vector(0, 0, 1)): return True return False class DRILLGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument PathLog.debug('obj: {} sub: {}'.format(obj, sub)) if hasattr(obj, "Shape") and sub: shape = obj.Shape @@ -136,21 +135,21 @@ class DRILLGate(PathBaseGate): return False -class FACEGate(PathBaseGate): # formerly PROFILEGate class using allow_ORIG method as allow() - def allow(self, doc, obj, sub): # pylint: disable=unused-argument +class FACEGate(PathBaseGate): # formerly PROFILEGate class using allow_ORIG method as allow() + def allow(self, doc, obj, sub): # pylint: disable=unused-argument profileable = False try: obj = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if obj.ShapeType == 'Compound': if sub and sub[0:4] == 'Face': profileable = True - elif obj.ShapeType == 'Face': # 3D Face, not flat, planar? - profileable = True # Was False + elif obj.ShapeType == 'Face': # 3D Face, not flat, planar? + profileable = True # Was False elif obj.ShapeType == 'Solid': if sub and sub[0:4] == 'Face': @@ -158,12 +157,12 @@ class FACEGate(PathBaseGate): # formerly PROFILEGate class using allow_ORIG met return profileable - def allow_ORIG(self, doc, obj, sub): # pylint: disable=unused-argument + def allow_ORIG(self, doc, obj, sub): # pylint: disable=unused-argument profileable = False try: obj = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if obj.ShapeType == 'Edge': @@ -193,13 +192,13 @@ class FACEGate(PathBaseGate): # formerly PROFILEGate class using allow_ORIG met class PROFILEGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument if sub and sub[0:4] == 'Edge': return True try: obj = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if obj.ShapeType == 'Compound': @@ -220,12 +219,12 @@ class PROFILEGate(PathBaseGate): class POCKETGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument pocketable = False try: obj = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False if obj.ShapeType == 'Edge': @@ -246,19 +245,19 @@ class POCKETGate(PathBaseGate): class ADAPTIVEGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument adaptive = True try: obj = obj.Shape - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except return False return adaptive class CONTOURGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument pass @@ -266,8 +265,9 @@ class PROBEGate: def allow(self, doc, obj, sub): pass + class TURNGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument PathLog.debug('obj: {} sub: {}'.format(obj, sub)) if hasattr(obj, "Shape") and sub: shape = obj.Shape @@ -276,8 +276,9 @@ class TURNGate(PathBaseGate): else: return False + class ALLGate(PathBaseGate): - def allow(self, doc, obj, sub): # pylint: disable=unused-argument + def allow(self, doc, obj, sub): # pylint: disable=unused-argument if sub and sub[0:6] == 'Vertex': return True if sub and sub[0:4] == 'Edge': @@ -336,6 +337,7 @@ def slotselect(): FreeCADGui.Selection.addSelectionGate(ALLGate()) FreeCAD.Console.PrintWarning("Slot Cutter Select Mode\n") + def surfaceselect(): gate = False if(MESHGate() or FACEGate()): @@ -343,6 +345,7 @@ def surfaceselect(): FreeCADGui.Selection.addSelectionGate(gate) FreeCAD.Console.PrintWarning("Surfacing Select Mode\n") + def vcarveselect(): FreeCADGui.Selection.addSelectionGate(VCARVEGate()) FreeCAD.Console.PrintWarning("Vcarve Select Mode\n") @@ -352,15 +355,16 @@ def probeselect(): FreeCADGui.Selection.addSelectionGate(PROBEGate()) FreeCAD.Console.PrintWarning("Probe Select Mode\n") + def customselect(): FreeCAD.Console.PrintWarning("Custom Select Mode\n") + def turnselect(): FreeCADGui.Selection.addSelectionGate(TURNGate()) FreeCAD.Console.PrintWarning("Turning Select Mode\n") - def select(op): opsel = {} opsel['Contour'] = contourselect # (depreciated) From eb3fbc0f9496e59ab405b00ca0e63f70c365aef3 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Thu, 29 Oct 2020 21:27:32 +0000 Subject: [PATCH 3/5] [Path] set the default max diameter --- src/Mod/Path/PathScripts/PathOp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index ea5b8e31c8..9b8c40a41c 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -361,6 +361,8 @@ class ObjectOp(object): if FeatureDiameters & features: obj.MinDiameter = '0 mm' obj.MaxDiameter = '0 mm' + if job.Stock: + obj.MaxDiameter = job.Stock.Shape.BoundBox.XLength if FeatureStartPoint & features: obj.UseStartPoint = False From e22de3bde14f7b07b1ab40efc9f446134856f006 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Thu, 29 Oct 2020 21:29:25 +0000 Subject: [PATCH 4/5] [Path] PEP8 whitespace fixes --- src/Mod/Path/PathScripts/PathOp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index 9b8c40a41c..39d2ea3054 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -92,7 +92,7 @@ class ObjectOp(object): FeatureBasePanels ... Base geometry support for Arch.Panels FeatureLocations ... Base location support FeatureCoolant ... Support for operation coolant - FeatureDiameters ... Support for turning operation diameters + FeatureDiameters ... Support for turning operation diameters The base class handles all base API and forwards calls to subclasses with an op prefix. For instance, an op is not expected to overwrite onChanged(), @@ -174,7 +174,7 @@ class ObjectOp(object): if FeatureDiameters & features: obj.addProperty("App::PropertyDistance", "MinDiameter", "Diameter", QtCore.QT_TRANSLATE_NOOP("PathOp", "Lower limit of the turning diameter")) obj.addProperty("App::PropertyDistance", "MaxDiameter", "Diameter", QtCore.QT_TRANSLATE_NOOP("PathOp", "Upper limit of the turning diameter.")) - + # members being set later self.commandlist = None self.horizFeed = None From 6be4352ea76b5a2bcac6044e035bfa7ea80850d3 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Thu, 29 Oct 2020 21:35:24 +0000 Subject: [PATCH 5/5] [Path] Tidy imports --- src/Mod/Path/PathScripts/PathOp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index 39d2ea3054..f103f3aa74 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -22,16 +22,16 @@ # * * # *************************************************************************** -import FreeCAD +import time + +from PySide import QtCore + import Path import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils - from PathScripts.PathUtils import waiting_effects -from PySide import QtCore -import time # lazily loaded modules from lazy_loader.lazy_loader import LazyLoader