From b834b369dd48b88728267a49def65316ef715e96 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Wed, 23 Jan 2019 22:13:22 -0800 Subject: [PATCH] Set feed rates to constructs commands for a tags. --- .../PathScripts/PathDressupHoldingTags.py | 61 ++++++------------- 1 file changed, 18 insertions(+), 43 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index 5e716128ed..9129cd523e 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -236,23 +236,25 @@ class Tag: class MapWireToTag: - def __init__(self, edge, tag, i, segm, maxZ): + def __init__(self, edge, tag, i, segm, maxZ, hSpeed, vSpeed): debugEdge(edge, 'MapWireToTag(%.2f, %.2f, %.2f)' % (i.x, i.y, i.z)) self.tag = tag self.segm = segm self.maxZ = maxZ + self.hSpeed = hSpeed + self.vSpeed = vSpeed if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), i): tail = edge self.commands = [] debugEdge(tail, '.........=') elif PathGeom.pointsCoincide(edge.valueAt(edge.LastParameter), i): debugEdge(edge, '++++++++ .') - self.commands = PathGeom.cmdsForEdge(edge, segm=segm) + self.commands = PathGeom.cmdsForEdge(edge, segm=segm, hSpeed = self.hSpeed, vSpeed = self.vSpeed) tail = None else: e, tail = PathGeom.splitEdgeAt(edge, i) debugEdge(e, '++++++++ .') - self.commands = PathGeom.cmdsForEdge(e, segm=segm) + self.commands = PathGeom.cmdsForEdge(e, segm=segm, hSpeed = self.hSpeed, vSpeed = self.vSpeed) debugEdge(tail, '.........-') self.initialEdge = edge self.tail = tail @@ -465,7 +467,7 @@ class MapWireToTag: if rapid: commands.append(Path.Command('G0', {'X': rapid.x, 'Y': rapid.y, 'Z': rapid.z})) rapid = None - commands.extend(PathGeom.cmdsForEdge(e, False, False, self.segm)) + commands.extend(PathGeom.cmdsForEdge(e, False, False, self.segm, hSpeed = self.hSpeed, vSpeed = self.vSpeed)) if rapid: commands.append(Path.Command('G0', {'X': rapid.x, 'Y': rapid.y, 'Z': rapid.z})) rapid = None @@ -476,7 +478,7 @@ class MapWireToTag: self.tag.enabled = False commands = [] for e in self.edges: - commands.extend(PathGeom.cmdsForEdge(e)) + commands.extend(PathGeom.cmdsForEdge(e, hSpeed = self.hSpeed, vSpeed = self.vSpeed)) failures.append(self) return commands return [] @@ -772,6 +774,12 @@ class ObjectTagDressup: self.mappers = [] mapper = None + tc = PathDressup.toolController(obj.Base) + horizFeed = tc.HorizFeed.Value + vertFeed = tc.VertFeed.Value + horizRapid = tc.HorizRapid.Value + vertRapid = tc.VertRapid.Value + while edge or lastEdge < len(pathData.edges): PathLog.debug("------- lastEdge = %d/%d.%d/%d" % (lastEdge, lastTag, t, len(tags))) if not edge: @@ -794,7 +802,7 @@ class ObjectTagDressup: t += 1 i = tags[tIndex].intersects(edge, edge.FirstParameter) if i and self.isValidTagStartIntersection(edge, i): - mapper = MapWireToTag(edge, tags[tIndex], i, segm, pathData.maxZ) + mapper = MapWireToTag(edge, tags[tIndex], i, segm, pathData.maxZ, hSpeed = horizFeed, vSpeed = vertFeed) self.mappers.append(mapper) edge = mapper.tail @@ -806,48 +814,15 @@ class ObjectTagDressup: v = edge.Vertexes[1] if not commands and PathGeom.isRoughly(0, v.X) and PathGeom.isRoughly(0, v.Y) and not PathGeom.isRoughly(0, v.Z): # The very first move is just to move to ClearanceHeight - commands.append(Path.Command('G0', {'Z': v.Z})) + commands.append(Path.Command('G0', {'Z': v.Z, 'F': horizRapid})) else: - commands.append(Path.Command('G0', {'X': v.X, 'Y': v.Y, 'Z': v.Z})) + commands.append(Path.Command('G0', {'X': v.X, 'Y': v.Y, 'Z': v.Z, 'F': vertRapid})) else: - commands.extend(PathGeom.cmdsForEdge(edge, segm=segm)) + commands.extend(PathGeom.cmdsForEdge(edge, segm=segm, hSpeed = horizFeed, vSpeed = vertFeed)) edge = None t = 0 - lastCmd = Path.Command('G0', {'X': 0.0, 'Y': 0.0, 'Z': 0.0}) - outCommands = [] - - tc = PathDressup.toolController(obj.Base) - horizFeed = tc.HorizFeed.Value - vertFeed = tc.VertFeed.Value - horizRapid = tc.HorizRapid.Value - vertRapid = tc.VertRapid.Value - - for cmd in commands: - params = cmd.Parameters - zVal = params.get('Z', None) - zVal2 = lastCmd.Parameters.get('Z', None) - - zVal = zVal and round(zVal, 8) - zVal2 = zVal2 and round(zVal2, 8) - - if cmd.Name in ['G1', 'G2', 'G3', 'G01', 'G02', 'G03']: - if False and zVal is not None and zVal2 != zVal: - params['F'] = vertFeed - else: - params['F'] = horizFeed - lastCmd = cmd - - elif cmd.Name in ['G0', 'G00']: - if zVal is not None and zVal2 != zVal: - params['F'] = vertRapid - else: - params['F'] = horizRapid - lastCmd = cmd - - outCommands.append(Path.Command(cmd.Name, params)) - - return Path.Path(outCommands) + return Path.Path(commands) def problems(self): return filter(lambda m: m.haveProblem, self.mappers)