From bf46ea4804f4eb1a75a1e84df41509b74082d745 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sun, 3 Jul 2016 12:02:24 -0500 Subject: [PATCH] Additional fixes for post processing. comment diameter instead of radius for compensated profile/surface ops opensbp improved pre processor is more explicit with XY values cmake copies opensbp postprocessor. Removed unnecessary file. --- src/Mod/Path/CMakeLists.txt | 1 + src/Mod/Path/PathScripts/PathMachine.py | 3 +-- src/Mod/Path/PathScripts/PathProfile.py | 2 +- src/Mod/Path/PathScripts/PathSurface.py | 2 +- src/Mod/Path/PathScripts/depth_params.py | 31 ----------------------- src/Mod/Path/PathScripts/linuxcnc_post.py | 2 +- src/Mod/Path/PathScripts/opensbp_pre.py | 20 ++++++++++----- 7 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 src/Mod/Path/PathScripts/depth_params.py diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index e84930e28..916b4a4bd 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -18,6 +18,7 @@ SET(PathScripts_SRCS PathScripts/PostUtils.py PathScripts/example_pre.py PathScripts/opensbp_pre.py + PathScripts/opensbp_post.py PathScripts/example_post.py PathScripts/linuxcnc_post.py PathScripts/centroid_post.py diff --git a/src/Mod/Path/PathScripts/PathMachine.py b/src/Mod/Path/PathScripts/PathMachine.py index b056e5288..378b5ad31 100644 --- a/src/Mod/Path/PathScripts/PathMachine.py +++ b/src/Mod/Path/PathScripts/PathMachine.py @@ -196,8 +196,7 @@ class _ViewProviderMachine: pass def setEdit(self, vobj, mode=0): # optional - # this is executed when the object is double-clicked in the tree - pass + return True def unsetEdit(self, vobj, mode=0): # optional # this is executed when the user cancels or terminates edit mode diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index a8292b74a..3a6c9407b 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -289,7 +289,7 @@ print "y - " + str(point.y) output += "(" + obj.Label + ")" if obj.Side != "On": - output += "(Compensated Tool Path: " + str(self.radius) + ")" + output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 06e12ce67..7ce3e73fc 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -282,7 +282,7 @@ class ObjectSurface: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" - output += "(Compensated Tool Path: " + str(self.radius) + ")" + output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" if obj.Base: for b in obj.Base: diff --git a/src/Mod/Path/PathScripts/depth_params.py b/src/Mod/Path/PathScripts/depth_params.py deleted file mode 100644 index 918c66757..000000000 --- a/src/Mod/Path/PathScripts/depth_params.py +++ /dev/null @@ -1,31 +0,0 @@ -import math - -class depth_params: - def __init__(self, clearance_height, rapid_safety_space, start_depth, step_down, z_finish_depth, z_thru_depth, final_depth, user_depths): - self.clearance_height = clearance_height - self.rapid_safety_space = math.fabs(rapid_safety_space) - self.start_depth = start_depth - self.step_down = math.fabs(step_down) - self.z_finish_depth = math.fabs(z_finish_depth) - self.z_thru_depth = math.fabs(z_thru_depth) - self.final_depth = final_depth - self.user_depths = user_depths - - def get_depths(self): - if self.user_depths != None: - depths = self.user_depths - else: - depth = self.final_depth - self.z_thru_depth - depths = [depth] - depth += self.z_finish_depth - if depth + 0.0000001 < self.start_depth: - if self.z_finish_depth > 0.0000001: depths.insert(0, depth) - depth += self.z_thru_depth - layer_count = int((self.start_depth - depth) / self.step_down - 0.0000001) + 1 - if layer_count > 0: - layer_depth = (self.start_depth - depth)/layer_count - for i in range(1, layer_count): - depth += layer_depth - depths.insert(0, depth) - - return depths diff --git a/src/Mod/Path/PathScripts/linuxcnc_post.py b/src/Mod/Path/PathScripts/linuxcnc_post.py index 10a5d71aa..1d3812c0b 100644 --- a/src/Mod/Path/PathScripts/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/linuxcnc_post.py @@ -49,7 +49,7 @@ LINENR = 100 # line number starting value # These globals will be reflected in the Machine configuration of the project UNITS = "G21" # G21 for metric, G20 for us standard -MACHINE_NAME = "Millstone" +MACHINE_NAME = "LinuxCNC" CORNER_MIN = {'x': 0, 'y': 0, 'z': 0} CORNER_MAX = {'x': 500, 'y': 300, 'z': 300} diff --git a/src/Mod/Path/PathScripts/opensbp_pre.py b/src/Mod/Path/PathScripts/opensbp_pre.py index 90404f58e..714d5bc66 100644 --- a/src/Mod/Path/PathScripts/opensbp_pre.py +++ b/src/Mod/Path/PathScripts/opensbp_pre.py @@ -46,13 +46,12 @@ TODO Many other OpenSBP commands not handled ''' +import FreeCAD +import os, Path AXIS = 'X','Y','Z','A','B' #OpenSBP always puts multiaxis move parameters in this order SPEEDS = 'XY','Z','A','B' -import FreeCAD -import os, Path - # to distinguish python built-in open function from the one declared below if open.__module__ == '__builtin__': pythonopen = open @@ -93,7 +92,7 @@ def parse(inputstring): movecommand = ['G1', 'G0', 'G02', 'G03'] for l in lines: - print l + # print l # remove any leftover trailing and preceding spaces l = l.strip() if not l: @@ -115,7 +114,8 @@ def parse(inputstring): s = "G0 " else: #feed move s = "G1 " - speed = lastfeedspeed["XY"] + speed = lastfeedspeed["XY"] + for i in range (1, len(words)): if words [i] == '': if last[AXIS[i-1]] == None: @@ -144,7 +144,10 @@ def parse(inputstring): last[words[0][1]] = words[1] - output += s + words[0][1] + str(words[1]) + " F" + speed + "\n" + output += s + for key, val in last.iteritems(): + if val is not None: + output += key + str(val) + " F" + speed + "\n" if words[0] in ["JS"]: #set jog speed for i in range (1, len(words)): @@ -187,9 +190,14 @@ def parse(inputstring): s = "G2" else: #CCW s = "G3" + + s += " X" + words[2] + " Y" + words[3] + " I" + words[4] + " J" + words[5] + " F" + str(lastfeedspeed["XY"]) output += s + '\n' + last["X"] = words[2] + last["Y"] = words[3] + #Make sure all appended paths have at least one move command. if any (x in output for x in movecommand): return_output.append(output)