From 0b9a16033168be5a910e0b1e0661d7c624045205 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 18 Feb 2021 01:36:04 -0600 Subject: [PATCH 01/13] Path: Apply LazyLoader for DraftGeomUtils module --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index b62cb53e45..847ea37b1f 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -37,6 +37,7 @@ from PySide import QtCore from lazy_loader.lazy_loader import LazyLoader ArchPanel = LazyLoader('ArchPanel', globals(), 'ArchPanel') Part = LazyLoader('Part', globals(), 'Part') +DraftGeomUtils = LazyLoader('DraftGeomUtils', globals(), 'DraftGeomUtils') __title__ = "Path Profile Operation" @@ -589,7 +590,6 @@ class ObjectProfile(PathAreaOp.ObjectOp): # Edges pre-processing def _processEdges(self, obj): - import DraftGeomUtils shapes = list() basewires = list() delPairs = list() From 45dab6b589957a1d6b832caed38405d91a9948b5 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 18 Feb 2021 01:39:07 -0600 Subject: [PATCH 02/13] Path: Change `HandleMultipleFeatures` default value to `Collectively` This fixes error when attempting to profile loop of vertical faces, thus maintaining original Profile Faces behavior by default for vertical looped face set. --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 847ea37b1f..4c744396c0 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -146,7 +146,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): return { 'AttemptInverseAngle': True, 'Direction': 'CW', - 'HandleMultipleFeatures': 'Individually', + 'HandleMultipleFeatures': 'Collectively', 'InverseAngle': False, 'JoinType': 'Round', 'LimitDepthToFace': True, From 8f4f30463555d412a4297207040d9dd33b4e00a6 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 18 Feb 2021 01:44:53 -0600 Subject: [PATCH 03/13] Path: Fix open-edge profiling for micro bit usage --- src/Mod/Path/PathScripts/PathProfile.py | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 4c744396c0..739d92a235 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -1337,7 +1337,10 @@ class ObjectProfile(PathAreaOp.ObjectOp): # PathLog.debug('_makeStop()') rad = self.radius ofstRad = self.ofstRadius - extra = self.radius / 10 + extra = self.radius / 5.0 + lng = 0.05 + med = lng / 2.0 + shrt = lng / 5.0 E = FreeCAD.Vector(pB.x, pB.y, 0) # endpoint C = FreeCAD.Vector(pA.x, pA.y, 0) # checkpoint @@ -1355,16 +1358,16 @@ class ObjectProfile(PathAreaOp.ObjectOp): # positive dist in _makePerp2DVector() is CCW rotation p1 = E if sType == 'BEG': - p2 = self._makePerp2DVector(C, E, -0.25) # E1 - p3 = self._makePerp2DVector(p1, p2, ofstRad + 1.0 + extra) # E2 - p4 = self._makePerp2DVector(p2, p3, 0.25 + ofstRad + extra) # E3 - p5 = self._makePerp2DVector(p3, p4, 1.0 + extra) # E4 + p2 = self._makePerp2DVector(C, E, -1 * shrt) # E1 + p3 = self._makePerp2DVector(p1, p2, ofstRad + lng + extra) # E2 + p4 = self._makePerp2DVector(p2, p3, shrt + ofstRad + extra) # E3 + p5 = self._makePerp2DVector(p3, p4, lng + extra) # E4 p6 = self._makePerp2DVector(p4, p5, ofstRad + extra) # E5 elif sType == 'END': - p2 = self._makePerp2DVector(C, E, 0.25) # E1 - p3 = self._makePerp2DVector(p1, p2, -1 * (ofstRad + 1.0 + extra)) # E2 - p4 = self._makePerp2DVector(p2, p3, -1 * (0.25 + ofstRad + extra)) # E3 - p5 = self._makePerp2DVector(p3, p4, -1 * (1.0 + extra)) # E4 + p2 = self._makePerp2DVector(C, E, shrt) # E1 + p3 = self._makePerp2DVector(p1, p2, -1 * (ofstRad + lng + extra)) # E2 + p4 = self._makePerp2DVector(p2, p3, -1 * (shrt + ofstRad + extra)) # E3 + p5 = self._makePerp2DVector(p3, p4, -1 * (lng + extra)) # E4 p6 = self._makePerp2DVector(p4, p5, -1 * (ofstRad + extra)) # E5 p7 = E # E6 L1 = Part.makeLine(p1, p2) @@ -1383,15 +1386,15 @@ class ObjectProfile(PathAreaOp.ObjectOp): # positive dist in _makePerp2DVector() is CCW rotation p1 = E if sType == 'BEG': - p2 = self._makePerp2DVector(C, E, -1 * (0.25 + abs(self.offsetExtra))) # left, 0.25 - p3 = self._makePerp2DVector(p1, p2, 0.25 + abs(self.offsetExtra)) - p4 = self._makePerp2DVector(p2, p3, (0.5 + abs(self.offsetExtra))) # FIRST POINT - p5 = self._makePerp2DVector(p3, p4, 0.25 + abs(self.offsetExtra)) # E1 SECOND + p2 = self._makePerp2DVector(C, E, -1 * (shrt + abs(self.offsetExtra))) # left, shrt + p3 = self._makePerp2DVector(p1, p2, shrt + abs(self.offsetExtra)) + p4 = self._makePerp2DVector(p2, p3, (med + abs(self.offsetExtra))) # FIRST POINT + p5 = self._makePerp2DVector(p3, p4, shrt + abs(self.offsetExtra)) # E1 SECOND elif sType == 'END': - p2 = self._makePerp2DVector(C, E, (0.25 + abs(self.offsetExtra))) # left, 0.25 - p3 = self._makePerp2DVector(p1, p2, -1 * (0.25 + abs(self.offsetExtra))) - p4 = self._makePerp2DVector(p2, p3, -1 * (0.5 + abs(self.offsetExtra))) # FIRST POINT - p5 = self._makePerp2DVector(p3, p4, -1 * (0.25 + abs(self.offsetExtra))) # E1 SECOND + p2 = self._makePerp2DVector(C, E, (shrt + abs(self.offsetExtra))) # left, shrt + p3 = self._makePerp2DVector(p1, p2, -1 * (shrt + abs(self.offsetExtra))) + p4 = self._makePerp2DVector(p2, p3, -1 * (med + abs(self.offsetExtra))) # FIRST POINT + p5 = self._makePerp2DVector(p3, p4, -1 * (shrt + abs(self.offsetExtra))) # E1 SECOND p6 = p1 # E4 L1 = Part.makeLine(p1, p2) L2 = Part.makeLine(p2, p3) From 91dd729d4e50652910a0164be74be4d476e44027 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 18 Feb 2021 01:43:11 -0600 Subject: [PATCH 04/13] Path: Fix error for undefined `profileshape` variable --- src/Mod/Path/PathScripts/PathProfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 739d92a235..8358e2ab7d 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -407,13 +407,11 @@ class ObjectProfile(PathAreaOp.ObjectOp): tup = shapeEnv, True, 'pathProfile', angle, axis, strDep, finDep shapes.append(tup) - if obj.processPerimeter: + if faces and obj.processPerimeter: if obj.HandleMultipleFeatures == 'Collectively': custDepthparams = self.depthparams cont = True - - if len(faces) > 0: - profileshape = Part.makeCompound(faces) + profileshape = Part.makeCompound(faces) if obj.LimitDepthToFace is True and obj.EnableRotation != 'Off': if profileshape.BoundBox.ZMin > obj.FinalDepth.Value: From 3a10ed5f2710b0f03bead030823a7da7cf68597f Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:01:59 -0600 Subject: [PATCH 05/13] Path: Fix feature selection and handling Fix error when working with selections containing edges and faces. This fix effectively processes edges and only passes faces on to next processing step. This simplifies the code a bit and changes some `obj.Base` references to `otherBase` to improve readability. Path: Improve `obj.Base` reading and processing `obj.Base` is first read in `self._processEdges()`. All edges are identified and processed there. Remaining features are saved in `remainingObjBaseFeatures` to be processed in the next section of the Profile code. Path: Change `if` to `elif` --- src/Mod/Path/PathScripts/PathProfile.py | 37 +++++++++++-------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 8358e2ab7d..4a06125a66 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -297,6 +297,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): baseSubsTuples = list() allTuples = list() edgeFaces = list() + remainingObjBaseFeatures = list() subCount = 0 self.isDebug = True if PathLog.getLevel(PathLog.thisModule()) == 4 else False self.inaccessibleMsg = translate('PathProfile', 'The selected edge(s) are inaccessible. If multiple, re-ordering selection might work.') @@ -323,12 +324,15 @@ class ObjectProfile(PathAreaOp.ObjectOp): # Pre-process Base Geometry to process edges if obj.Base and len(obj.Base) > 0: # The user has selected subobjects from the base. Process each. - shapes.extend(self._processEdges(obj)) + shapes.extend(self._processEdges(obj, remainingObjBaseFeatures)) - if obj.Base and len(obj.Base) > 0: # The user has selected subobjects from the base. Process each. + if obj.Base and len(obj.Base) > 0 and not remainingObjBaseFeatures: + # Edges were already processed, or whole model targeted. + PathLog.debug("remainingObjBaseFeatures is False") + elif remainingObjBaseFeatures and len(remainingObjBaseFeatures) > 0: # Process remaining features after edges processed above. if obj.EnableRotation != 'Off': - for p in range(0, len(obj.Base)): - (base, subsList) = obj.Base[p] + for p in range(0, len(remainingObjBaseFeatures)): + (base, subsList) = remainingObjBaseFeatures[p] for sub in subsList: subCount += 1 shape = getattr(base.Shape, sub) @@ -353,12 +357,11 @@ class ObjectProfile(PathAreaOp.ObjectOp): # Efor else: stock = PathUtils.findParentJob(obj).Stock - for (base, subList) in obj.Base: + for (base, subList) in remainingObjBaseFeatures: baseSubsTuples.append((base, subList, 0.0, 'X', stock)) # Eif - # for base in obj.Base: - finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0 + # for base in remainingObjBaseFeatures: for (base, subsList, angle, axis, stock) in baseSubsTuples: holes = [] faces = [] @@ -587,16 +590,15 @@ class ObjectProfile(PathAreaOp.ObjectOp): return shapeTups # Edges pre-processing - def _processEdges(self, obj): + def _processEdges(self, obj, remainingObjBaseFeatures): shapes = list() basewires = list() - delPairs = list() ezMin = None self.cutOut = self.tool.Diameter for p in range(0, len(obj.Base)): (base, subsList) = obj.Base[p] - tmpSubs = list() + keepFaces = list() edgelist = list() for sub in subsList: shape = getattr(base.Shape, sub) @@ -605,16 +607,14 @@ class ObjectProfile(PathAreaOp.ObjectOp): edgelist.append(getattr(base.Shape, sub)) # save faces for regular processing if isinstance(shape, Part.Face): - tmpSubs.append(sub) + keepFaces.append(sub) if len(edgelist) > 0: basewires.append((base, DraftGeomUtils.findWires(edgelist))) if ezMin is None or base.Shape.BoundBox.ZMin < ezMin: ezMin = base.Shape.BoundBox.ZMin - # If faces - if len(tmpSubs) == 0: # all edges in subsList = remove pair in obj.Base - delPairs.append(p) - elif len(edgelist) > 0: # some edges in subsList were extracted, return faces only to subsList - obj.Base[p] = (base, tmpSubs) + + if len(keepFaces) > 0: # save faces for returning and processing + remainingObjBaseFeatures.append((base, keepFaces)) for base, wires in basewires: for wire in wires: @@ -669,11 +669,6 @@ class ObjectProfile(PathAreaOp.ObjectOp): # Efor # Efor - delPairs.sort(reverse=True) - for p in delPairs: - # obj.Base.pop(p) - pass - return shapes def _flattenWire(self, obj, wire, trgtDep): From d7483f6e8564cd1992ec793b85913768e1968f10 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Thu, 18 Feb 2021 02:21:21 -0600 Subject: [PATCH 06/13] Path: Fix range() input type per gcc-7 build --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 4a06125a66..a0f3172509 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -1263,7 +1263,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): nt = 4 # desired + 1 mid = LE / nt spc = self.radius / 10 - for i in range(0, nt): + for i in range(0, int(nt)): if i == 0: if e == 0: if LE > 0.2: From b3fc4fcf17a9f7c4c0792b5a5fa02897ca08a6ee Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:12:05 -0600 Subject: [PATCH 07/13] Path: Fix spacing typo --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index a0f3172509..027e70193e 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -635,7 +635,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): else: # Attempt open-edges profile if self.JOB.GeometryTolerance.Value == 0.0: - msg = self.JOB.Label + '.GeometryTolerance = 0.0.' + msg = self.JOB.Label + '.GeometryTolerance = 0.0. ' msg += translate('PathProfile', 'Please set to an acceptable value greater than zero.') PathLog.error(msg) else: From 8e234290ef8421f54646a98371e29a8868b7ef3c Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:14:15 -0600 Subject: [PATCH 08/13] Path: Catch `openEdges` error if `None` --- src/Mod/Path/PathScripts/PathProfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 027e70193e..948c1dec56 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -660,8 +660,9 @@ class ObjectProfile(PathAreaOp.ObjectOp): else: PathLog.error(self.inaccessibleMsg) - tup = openEdges, False, 'OpenEdge', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value - shapes.append(tup) + if openEdges: + tup = openEdges, False, 'OpenEdge', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value + shapes.append(tup) else: PathLog.error(self.inaccessibleMsg) # Eif From 2b4158addc87efecf6198ec61bd2220bd28650d3 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:15:24 -0600 Subject: [PATCH 09/13] Path: Fix incorrect empty data type return --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 948c1dec56..faac61a9f7 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -936,7 +936,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): osArea = ofstShp.Area except Exception as ee: PathLog.error('No area to offset shape returned.\n{}'.format(ee)) - return False + return list() self._addDebugObject('OffsetShape', ofstShp) From 215967fe784bccb1cf0f0ec03e49c1b5304e3673 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 19 Feb 2021 21:16:26 -0600 Subject: [PATCH 10/13] Path: Catch error if `ofstShape` has no `Area` attribute --- src/Mod/Path/PathScripts/PathProfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index faac61a9f7..da702108c9 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -933,7 +933,11 @@ class ObjectProfile(PathAreaOp.ObjectOp): # CHECK for ZERO area of offset shape try: - osArea = ofstShp.Area + if hasattr(ofstShp, "Area"): + osArea = ofstShp.Area + else: + PathLog.error('No area to offset shape returned.\n') + return list() except Exception as ee: PathLog.error('No area to offset shape returned.\n{}'.format(ee)) return list() From 1b3205de20834482f8b347481a291bcb0626f821 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 20 Feb 2021 11:42:36 -0600 Subject: [PATCH 11/13] Path: Add error for incorrect open-edge usage When profiling open edges, the user must currently select a top edge and then set the Final Depth manually to a value below the selected edge(s). This fix provides the user with feedback for the empty path generated. --- src/Mod/Path/PathScripts/PathProfile.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index da702108c9..9a33868067 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -640,7 +640,8 @@ class ObjectProfile(PathAreaOp.ObjectOp): PathLog.error(msg) else: flattened = self._flattenWire(obj, wire, obj.FinalDepth.Value) - if flattened: + zDiff = math.fabs(wire.BoundBox.ZMin - obj.FinalDepth.Value) + if flattened and zDiff >= self.JOB.GeometryTolerance.Value: cutWireObjs = False openEdges = list() passOffsets = [self.ofstRadius] @@ -664,7 +665,11 @@ class ObjectProfile(PathAreaOp.ObjectOp): tup = openEdges, False, 'OpenEdge', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value shapes.append(tup) else: - PathLog.error(self.inaccessibleMsg) + if zDiff < self.JOB.GeometryTolerance.Value: + msg = translate('PathProfile', 'Check edge selection and Final Depth requirements for profiling open edge(s).') + PathLog.error(msg) + else: + PathLog.error(self.inaccessibleMsg) # Eif # Eif # Efor From a961fbee866d3ea50a162fc972465c2f820b4f94 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 20 Feb 2021 11:37:26 -0600 Subject: [PATCH 12/13] Path: Remove unnecessary line return --- src/Mod/Path/PathScripts/PathProfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 9a33868067..9dbc935365 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -941,7 +941,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): if hasattr(ofstShp, "Area"): osArea = ofstShp.Area else: - PathLog.error('No area to offset shape returned.\n') + PathLog.error('No area to offset shape returned.') return list() except Exception as ee: PathLog.error('No area to offset shape returned.\n{}'.format(ee)) From 2b35419e5574d4772d81122756d704239cc39a3d Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 20 Feb 2021 12:32:17 -0600 Subject: [PATCH 13/13] Path: LGTM cleanup --- src/Mod/Path/PathScripts/PathProfile.py | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index 9dbc935365..173aaaa401 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -172,7 +172,8 @@ class ObjectProfile(PathAreaOp.ObjectOp): if isinstance(val, int) or isinstance(val, float): setVal = True if setVal: - propVal = getattr(prop, 'Value') + # propVal = getattr(prop, 'Value') + # Need to check if `val` below should be `propVal` commented out above setattr(prop, 'Value', val) else: setattr(obj, n, val) @@ -215,7 +216,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): return 'Contour' # return first geometry type selected - (base, subsList) = obj.Base[0] + (_, subsList) = obj.Base[0] return subsList[0][:4] def areaOpOnDocumentRestored(self, obj): @@ -296,7 +297,6 @@ class ObjectProfile(PathAreaOp.ObjectOp): shapes = [] baseSubsTuples = list() allTuples = list() - edgeFaces = list() remainingObjBaseFeatures = list() subCount = 0 self.isDebug = True if PathLog.getLevel(PathLog.thisModule()) == 4 else False @@ -349,7 +349,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): subList = [] for o in range(0, len(Tags)): subList = [] - for (base, sub, tag, angle, axis, stock) in Grps[o]: + for (base, sub, _, angle, axis, stock) in Grps[o]: subList.append(sub) pair = base, subList, angle, axis, stock @@ -381,7 +381,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): else: ignoreSub = base.Name + '.' + sub msg = translate('PathProfile', "Found a selected object which is not a face. Ignoring:") - # FreeCAD.Console.PrintWarning(msg + " {}\n".format(ignoreSub)) + PathLog.warning(msg + " {}".format(ignoreSub)) # Identify initial Start and Final Depths finDep = obj.FinalDepth.Value @@ -705,14 +705,14 @@ class ObjectProfile(PathAreaOp.ObjectOp): # Open-edges methods def _getCutAreaCrossSection(self, obj, base, origWire, flatWire): PathLog.debug('_getCutAreaCrossSection()') - FCAD = FreeCAD.ActiveDocument + # FCAD = FreeCAD.ActiveDocument tolerance = self.JOB.GeometryTolerance.Value toolDiam = 2 * self.radius # self.radius defined in PathAreaOp or PathProfileBase modules minBfr = toolDiam * 1.25 bbBfr = (self.ofstRadius * 2) * 1.25 if bbBfr < minBfr: bbBfr = minBfr - fwBB = flatWire.BoundBox + # fwBB = flatWire.BoundBox wBB = origWire.BoundBox minArea = (self.ofstRadius - tolerance)**2 * math.pi @@ -741,10 +741,10 @@ class ObjectProfile(PathAreaOp.ObjectOp): pe = FreeCAD.Vector(Ve.X, Ve.Y, fdv) # Identify endpoints connecting circle center and diameter - vectDist = pe.sub(pb) - diam = vectDist.Length - cntr = vectDist.multiply(0.5).add(pb) - R = diam / 2 + # vectDist = pe.sub(pb) + # diam = vectDist.Length + # cntr = vectDist.multiply(0.5).add(pb) + # R = diam / 2 # Obtain beginning point perpendicular points if blen > 0.1: @@ -940,6 +940,8 @@ class ObjectProfile(PathAreaOp.ObjectOp): try: if hasattr(ofstShp, "Area"): osArea = ofstShp.Area + if osArea: # Make LGTM parser happy + pass else: PathLog.error('No area to offset shape returned.') return list() @@ -962,7 +964,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): if N[4] < min0: min0 = N[4] min0i = n - (w0, vi0, pnt0, vrt0, d0) = NEAR0[0] # min0i + (w0, vi0, pnt0, _, _) = NEAR0[0] # min0i near0Shp = Part.makeLine(cent0, pnt0) self._addDebugObject('Near0', near0Shp) @@ -974,7 +976,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): if N[4] < min1: min1 = N[4] min1i = n - (w1, vi1, pnt1, vrt1, d1) = NEAR1[0] # min1i + (w1, vi1, pnt1, _, _) = NEAR1[0] # min1i near1Shp = Part.makeLine(cent1, pnt1) self._addDebugObject('Near1', near1Shp) @@ -1301,7 +1303,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): tagCnt += nt intTags.append(intTObj) extTags.append(extTObj) - tagArea = math.pi * tagRad**2 * tagCnt + # tagArea = math.pi * tagRad**2 * tagCnt iTAG = Part.makeCompound(intTags) eTAG = Part.makeCompound(extTags) @@ -1338,7 +1340,6 @@ class ObjectProfile(PathAreaOp.ObjectOp): def _makeStop(self, sType, pA, pB, lbl): # PathLog.debug('_makeStop()') - rad = self.radius ofstRad = self.ofstRadius extra = self.radius / 5.0 lng = 0.05 @@ -1347,7 +1348,6 @@ class ObjectProfile(PathAreaOp.ObjectOp): E = FreeCAD.Vector(pB.x, pB.y, 0) # endpoint C = FreeCAD.Vector(pA.x, pA.y, 0) # checkpoint - lenEC = E.sub(C).Length if self.useComp is True or (self.useComp is False and self.offsetExtra != 0): # 'L' stop shape and edge map