From 58ba0e1c39b491b3479557fb047f481246569375 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 12 May 2020 17:43:21 -0500 Subject: [PATCH 1/3] Path: Fix related to `linkStockAndModel` checkbox. The StockEdit class is reused by BoundaryDressup, and this checkbox does not exist in its UI panel. --- src/Mod/Path/PathScripts/PathJobGui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index a2371ed8ad..a3abe0374e 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -404,7 +404,8 @@ class StockFromBaseBoundBoxEdit(StockEdit): self.form.stockExtXpos.textChanged.connect(self.checkXpos) self.form.stockExtYpos.textChanged.connect(self.checkYpos) self.form.stockExtZpos.textChanged.connect(self.checkZpos) - self.form.linkStockAndModel.setChecked(True) + if hasattr(self.form, 'linkStockAndModel'): + self.form.linkStockAndModel.setChecked(True) def checkXpos(self): self.trackXpos = self.form.stockExtXneg.text() == self.form.stockExtXpos.text() From a679356b4839ee751522c2ca4bfd19399d40542a Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Wed, 13 May 2020 21:52:15 -0500 Subject: [PATCH 2/3] Path: Add `if edge:` test clause `If edge:` handles 'NoneType' edges returned from `PathGeom.edgeForCmd()`. Includes some PEP8 formatting. --- .../PathScripts/PathDressupPathBoundary.py | 131 ++++++++++-------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupPathBoundary.py b/src/Mod/Path/PathScripts/PathDressupPathBoundary.py index 8cf186021e..488734d972 100644 --- a/src/Mod/Path/PathScripts/PathDressupPathBoundary.py +++ b/src/Mod/Path/PathScripts/PathDressupPathBoundary.py @@ -34,13 +34,15 @@ import PathScripts.PathUtils as PathUtils from PySide import QtCore PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) -#PathLog.trackModule(PathLog.thisModule()) +# PathLog.trackModule(PathLog.thisModule()) + def _vstr(v): if v: return "(%.2f, %.2f, %.2f)" % (v.x, v.y, v.z) return '-' + class DressupPathBoundary(object): def __init__(self, obj, base, job): @@ -57,6 +59,7 @@ class DressupPathBoundary(object): def __getstate__(self): return None + def __setstate__(self, state): return None @@ -111,71 +114,77 @@ class DressupPathBoundary(object): for cmd in obj.Base.Path.Commands[1:]: if cmd.Name in PathGeom.CmdMoveAll: edge = PathGeom.edgeForCmd(cmd, pos) - inside = edge.common(boundary).Edges - outside = edge.cut(boundary).Edges - if not obj.Inside: - t = inside - inside = outside - outside = t - # it's really a shame that one cannot trust the sequence and/or - # orientation of edges - if 1 == len(inside) and 0 == len(outside): - PathLog.track(_vstr(pos), _vstr(lastExit), ' + ', cmd) - # cmd fully included by boundary - if lastExit: - commands.extend(self.boundaryCommands(obj, lastExit, pos, tc.VertFeed.Value)) - lastExit = None - commands.append(cmd) - pos = PathGeom.commandEndPoint(cmd, pos) - elif 0 == len(inside) and 1 == len(outside): - PathLog.track(_vstr(pos), _vstr(lastExit), ' - ', cmd) - # cmd fully excluded by boundary - if not lastExit: - lastExit = pos - pos = PathGeom.commandEndPoint(cmd, pos) - else: - PathLog.track(_vstr(pos), _vstr(lastExit), len(inside), len(outside), cmd) - # cmd pierces boundary - while inside or outside: - ie = [e for e in inside if PathGeom.edgeConnectsTo(e, pos)] - PathLog.track(ie) - if ie: - e = ie[0] - ptL = e.valueAt(e.LastParameter) - flip = PathGeom.pointsCoincide(pos, ptL) - newPos = e.valueAt(e.FirstParameter) if flip else ptL - # inside edges are taken at this point (see swap of inside/outside - # above - so we can just connect the dots ... - if lastExit: - commands.extend(self.boundaryCommands(obj, lastExit, pos, tc.VertFeed.Value)) - lastExit = None - PathLog.track(e, flip) - commands.extend(PathGeom.cmdsForEdge(e, flip, False,50,tc.HorizFeed.Value,tc.VertFeed.Value)) # add missing HorizFeed to G2 paths - inside.remove(e) - pos = newPos - lastExit = newPos - else: - oe = [e for e in outside if PathGeom.edgeConnectsTo(e, pos)] - PathLog.track(oe) - if oe: - e = oe[0] + if edge: + inside = edge.common(boundary).Edges + outside = edge.cut(boundary).Edges + if not obj.Inside: + t = inside + inside = outside + outside = t + # it's really a shame that one cannot trust the sequence and/or + # orientation of edges + if 1 == len(inside) and 0 == len(outside): + PathLog.track(_vstr(pos), _vstr(lastExit), ' + ', cmd) + # cmd fully included by boundary + if lastExit: + commands.extend(self.boundaryCommands(obj, lastExit, pos, tc.VertFeed.Value)) + lastExit = None + commands.append(cmd) + pos = PathGeom.commandEndPoint(cmd, pos) + elif 0 == len(inside) and 1 == len(outside): + PathLog.track(_vstr(pos), _vstr(lastExit), ' - ', cmd) + # cmd fully excluded by boundary + if not lastExit: + lastExit = pos + pos = PathGeom.commandEndPoint(cmd, pos) + else: + PathLog.track(_vstr(pos), _vstr(lastExit), len(inside), len(outside), cmd) + # cmd pierces boundary + while inside or outside: + ie = [e for e in inside if PathGeom.edgeConnectsTo(e, pos)] + PathLog.track(ie) + if ie: + e = ie[0] ptL = e.valueAt(e.LastParameter) flip = PathGeom.pointsCoincide(pos, ptL) newPos = e.valueAt(e.FirstParameter) if flip else ptL - # outside edges are never taken at this point (see swap of - # inside/outside above) - so just move along ... - outside.remove(e) + # inside edges are taken at this point (see swap of inside/outside + # above - so we can just connect the dots ... + if lastExit: + commands.extend(self.boundaryCommands(obj, lastExit, pos, tc.VertFeed.Value)) + lastExit = None + PathLog.track(e, flip) + commands.extend(PathGeom.cmdsForEdge(e, flip, False, 50, tc.HorizFeed.Value, tc.VertFeed.Value)) # add missing HorizFeed to G2 paths + inside.remove(e) pos = newPos + lastExit = newPos else: - PathLog.error('huh?') - import Part - Part.show(Part.Vertex(pos), 'pos') - for e in inside: - Part.show(e, 'ei') - for e in outside: - Part.show(e, 'eo') - raise Exception('This is not supposed to happen') - #pos = PathGeom.commandEndPoint(cmd, pos) + oe = [e for e in outside if PathGeom.edgeConnectsTo(e, pos)] + PathLog.track(oe) + if oe: + e = oe[0] + ptL = e.valueAt(e.LastParameter) + flip = PathGeom.pointsCoincide(pos, ptL) + newPos = e.valueAt(e.FirstParameter) if flip else ptL + # outside edges are never taken at this point (see swap of + # inside/outside above) - so just move along ... + outside.remove(e) + pos = newPos + else: + PathLog.error('huh?') + import Part + Part.show(Part.Vertex(pos), 'pos') + for e in inside: + Part.show(e, 'ei') + for e in outside: + Part.show(e, 'eo') + raise Exception('This is not supposed to happen') + # Eif + # Eif + # Ewhile + # Eif + # pos = PathGeom.commandEndPoint(cmd, pos) + # Eif else: PathLog.track('no-move', cmd) commands.append(cmd) From ffc353f2944239cd2eaf333b5f2e72aa28ac6e4e Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Wed, 13 May 2020 16:33:13 -0500 Subject: [PATCH 3/3] Path: Fix for `.extrude()` vector roughly zero --- 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 784632b48c..6745b143e0 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -627,7 +627,7 @@ class ObjectProfile(PathAreaOp.ObjectOp): PathLog.debug('Wire is not horizontally co-planar. Flattening it.') # Extrude non-horizontal wire - extFwdLen = wBB.ZLength * 2.2 + extFwdLen = (wBB.ZLength + 2.0) * 2.0 mbbEXT = wire.extrude(FreeCAD.Vector(0, 0, extFwdLen)) # Create cross-section of shape and translate