From f1d7a4277d15eca6e8b93957613e454800b2aa85 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Wed, 24 Mar 2021 08:54:05 -0500 Subject: [PATCH] removed PathUtils import from all post-processors to avoid the deleted proxy error I removed or commented out code using this import. In all cases, the import was used to get descriptive information from the Job --- src/Mod/Path/PathScripts/post/fanuc_post.py | 33 ++-------------- .../Path/PathScripts/post/heidenhain_post.py | 39 ++++++------------- .../Path/PathScripts/post/linuxcnc_post.py | 21 +--------- .../Path/PathScripts/post/mach3_mach4_post.py | 29 +------------- src/Mod/Path/PathScripts/post/philips_post.py | 18 ++++----- 5 files changed, 26 insertions(+), 114 deletions(-) diff --git a/src/Mod/Path/PathScripts/post/fanuc_post.py b/src/Mod/Path/PathScripts/post/fanuc_post.py index d2bb6acb0e65..3eee41519d9d 100644 --- a/src/Mod/Path/PathScripts/post/fanuc_post.py +++ b/src/Mod/Path/PathScripts/post/fanuc_post.py @@ -30,7 +30,6 @@ import shlex import os.path from PathScripts import PostUtils -from PathScripts import PathUtils TOOLTIP = ''' This is a postprocessor file for the Path workbench. It is used to @@ -154,7 +153,7 @@ def processArguments(argstring): if args.no_tlo: USE_TLO = False if args.no_axis_modal: - OUTPUT_DOUBLES = true + OUTPUT_DOUBLES = True except Exception: # pylint: disable=broad-except return False @@ -171,7 +170,7 @@ def export(objectslist, filename, argstring): global UNIT_SPEED_FORMAT global HORIZRAPID global VERTRAPID - + for obj in objectslist: if not hasattr(obj, "Path"): print("the object " + obj.Name + " is not a path. Please select only path and Compounds.") @@ -206,34 +205,10 @@ def export(objectslist, filename, argstring): if not obj.Base.Active: continue - # fetch machine details - job = PathUtils.findParentJob(obj) - - myMachine = 'not set' - - if hasattr(job, "MachineName"): - myMachine = job.MachineName - - if hasattr(job, "MachineUnits"): - if job.MachineUnits == "Metric": - UNITS = "G21" - UNIT_FORMAT = 'mm' - UNIT_SPEED_FORMAT = 'mm/min' - else: - UNITS = "G20" - UNIT_FORMAT = 'in' - UNIT_SPEED_FORMAT = 'in/min' - - if hasattr(job, "SetupSheet"): - if hasattr(job.SetupSheet, "HorizRapid"): - HORIZRAPID = Units.Quantity(job.SetupSheet.HorizRapid, FreeCAD.Units.Velocity) - if hasattr(job.SetupSheet, "VertRapid"): - VERTRAPID = Units.Quantity(job.SetupSheet.HorizRapid, FreeCAD.Units.Velocity) - # do the pre_op if OUTPUT_COMMENTS: gcode += linenumber() + "(BEGIN OPERATION: %s)\n" % obj.Label.upper() - gcode += linenumber() + "(MACHINE: %s, %s)\n" % (myMachine.upper(), UNIT_SPEED_FORMAT.upper()) + gcode += linenumber() + "(MACHINE UNITS: %s)\n" % (UNIT_SPEED_FORMAT.upper()) for line in PRE_OPERATION.splitlines(True): gcode += linenumber() + line @@ -459,7 +434,6 @@ def parse(pathobj): outstring.append(param + str(int(c.Parameters['D']))) elif param == 'S': outstring.append(param + str(int(c.Parameters['S']))) - currentSpeed = int(c.Parameters['S']) else: if (not OUTPUT_DOUBLES) and (param in currLocation) and (currLocation[param] == c.Parameters[param]): continue @@ -482,7 +456,6 @@ def parse(pathobj): # Check for Tool Change: if command == 'M6': # stop the spindle - currentSpeed = 0 out += linenumber() + "M5\n" for line in TOOL_CHANGE.splitlines(True): out += linenumber() + line diff --git a/src/Mod/Path/PathScripts/post/heidenhain_post.py b/src/Mod/Path/PathScripts/post/heidenhain_post.py index 42219952b0dc..acfc1a9b2200 100644 --- a/src/Mod/Path/PathScripts/post/heidenhain_post.py +++ b/src/Mod/Path/PathScripts/post/heidenhain_post.py @@ -20,14 +20,10 @@ # HEDENHAIN Post-Processor for FreeCAD -import FreeCAD -from FreeCAD import Units import argparse -import time import shlex import PathScripts from PathScripts import PostUtils -from PathScripts import PathUtils import math #**************************************************************************# @@ -261,11 +257,8 @@ def export(objectslist, filename, argstring): global LBLIZE_STAUS Object_Kind = None - Feed_Rapid = False Feed = 0 - Spindle_RPM = 0 Spindle_Active = False - ToolId = "" Compensation = "0" params = [ 'X', 'Y', 'Z', @@ -360,22 +353,14 @@ def export(objectslist, filename, argstring): for c in obj.Path.Commands: Cmd_Count += 1 - outstring = [] command = c.Name if command != 'G0': command = command.replace('G0','G') # normalize: G01 -> G1 - Feed_Rapid = False - else: - Feed_Rapid = True for param in params: if param in c.Parameters: if param == 'F': Feed = c.Parameters['F'] - elif param == 'S': - Spindle_RPM = c.Parameters['S'] # Could be deleted if tool it's OK - elif param == 'T': - ToolId = c.Parameters['T'] # Could be deleted if tool it's OK if command == 'G90': G_FUNCTION_STORE['G90'] = True @@ -474,21 +459,21 @@ def export(objectslist, filename, argstring): def HEIDEN_Begin(ActualJob): #use Label for program name global UNITS - JobParent = PathUtils.findParentJob(ActualJob[0]) - if hasattr(JobParent, "Label"): - program_id = JobParent.Label - else: - program_id = "NEW" - return "BEGIN PGM " + str(program_id) + " " + UNITS + # JobParent = PathUtils.findParentJob(ActualJob[0]) + # if hasattr(JobParent, "Label"): + # program_id = JobParent.Label + # else: + # program_id = "NEW" + return "BEGIN PGM {}".format(UNITS) def HEIDEN_End(ActualJob): #use Label for program name global UNITS - JobParent = PathUtils.findParentJob(ActualJob[0]) - if hasattr(JobParent, "Label"): - program_id = JobParent.Label - else: - program_id = "NEW" - return "END PGM " + program_id + " " + UNITS + # JobParent = PathUtils.findParentJob(ActualJob[0]) + # if hasattr(JobParent, "Label"): + # program_id = JobParent.Label + # else: + # program_id = "NEW" + return "END PGM {}".format(UNITS) #def HEIDEN_ToolDef(tool_id, tool_length, tool_radius): # old machines don't have tool table, need tooldef list # return "TOOL DEF " + tool_id + " R" + "{:.3f}".format(tool_length) + " L" + "{:.3f}".format(tool_radius) diff --git a/src/Mod/Path/PathScripts/post/linuxcnc_post.py b/src/Mod/Path/PathScripts/post/linuxcnc_post.py index 6f22d93142c5..c102528d6b36 100644 --- a/src/Mod/Path/PathScripts/post/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/post/linuxcnc_post.py @@ -29,7 +29,6 @@ import datetime import shlex from PathScripts import PostUtils -from PathScripts import PathUtils TOOLTIP = ''' This is a postprocessor file for the Path workbench. It is used to @@ -193,28 +192,10 @@ def export(objectslist, filename, argstring): if not obj.Base.Active: continue - # fetch machine details - job = PathUtils.findParentJob(obj) - - myMachine = 'not set' - - if hasattr(job, "MachineName"): - myMachine = job.MachineName - - if hasattr(job, "MachineUnits"): - if job.MachineUnits == "Metric": - UNITS = "G21" - UNIT_FORMAT = 'mm' - UNIT_SPEED_FORMAT = 'mm/min' - else: - UNITS = "G20" - UNIT_FORMAT = 'in' - UNIT_SPEED_FORMAT = 'in/min' - # do the pre_op if OUTPUT_COMMENTS: gcode += linenumber() + "(begin operation: %s)\n" % obj.Label - gcode += linenumber() + "(machine: %s, %s)\n" % (myMachine, UNIT_SPEED_FORMAT) + gcode += linenumber() + "(machine units: %s)\n" % (UNIT_SPEED_FORMAT) for line in PRE_OPERATION.splitlines(True): gcode += linenumber() + line diff --git a/src/Mod/Path/PathScripts/post/mach3_mach4_post.py b/src/Mod/Path/PathScripts/post/mach3_mach4_post.py index f2ca58259d74..b34f8cae81f7 100644 --- a/src/Mod/Path/PathScripts/post/mach3_mach4_post.py +++ b/src/Mod/Path/PathScripts/post/mach3_mach4_post.py @@ -28,7 +28,6 @@ import datetime import shlex from PathScripts import PostUtils -from PathScripts import PathUtils TOOLTIP = ''' This is a postprocessor file for the Path workbench. It is used to @@ -161,8 +160,6 @@ def export(objectslist, filename, argstring): global UNITS global UNIT_FORMAT global UNIT_SPEED_FORMAT - global HORIZRAPID - global VERTRAPID for obj in objectslist: if not hasattr(obj, "Path"): @@ -195,34 +192,10 @@ def export(objectslist, filename, argstring): if not obj.Base.Active: continue - # fetch machine details - job = PathUtils.findParentJob(obj) - - myMachine = 'not set' - - if hasattr(job, "MachineName"): - myMachine = job.MachineName - - if hasattr(job, "MachineUnits"): - if job.MachineUnits == "Metric": - UNITS = "G21" - UNIT_FORMAT = 'mm' - UNIT_SPEED_FORMAT = 'mm/min' - else: - UNITS = "G20" - UNIT_FORMAT = 'in' - UNIT_SPEED_FORMAT = 'in/min' - - if hasattr(job, "SetupSheet"): - if hasattr(job.SetupSheet, "HorizRapid"): - HORIZRAPID = Units.Quantity(job.SetupSheet.HorizRapid, FreeCAD.Units.Velocity) - if hasattr(job.SetupSheet, "VertRapid"): - VERTRAPID = Units.Quantity(job.SetupSheet.HorizRapid, FreeCAD.Units.Velocity) - # do the pre_op if OUTPUT_COMMENTS: gcode += linenumber() + "(begin operation: %s)\n" % obj.Label - gcode += linenumber() + "(machine: %s, %s)\n" % (myMachine, UNIT_SPEED_FORMAT) + gcode += linenumber() + "(machine: %s, %s)\n" % (MACHINE_NAME, UNIT_SPEED_FORMAT) for line in PRE_OPERATION.splitlines(True): gcode += linenumber() + line diff --git a/src/Mod/Path/PathScripts/post/philips_post.py b/src/Mod/Path/PathScripts/post/philips_post.py index f06d2d666d2c..d48a5265c974 100644 --- a/src/Mod/Path/PathScripts/post/philips_post.py +++ b/src/Mod/Path/PathScripts/post/philips_post.py @@ -20,15 +20,14 @@ #* * #*************************************************************************** -# reload in python console: -# import generic_post -# reload(generic_post) +# 03-24-2021 Sliptonic: I've removed teh PathUtils import and job lookup +# post processors shouldn't be reaching back to the job. This can cause a +# proxy error. import FreeCAD import argparse import time from PathScripts import PostUtils -from PathScripts import PathUtils import math TOOLTIP = '''Post processor for Maho M 600E mill @@ -232,16 +231,17 @@ def processArguments(argstring): SHOW_EDITOR = False def mkHeader(selection): - job = PathUtils.findParentJob(selection[0]) + # job = PathUtils.findParentJob(selection[0]) # this is within a function, because otherwise filename and time don't change when changing the FreeCAD project # now = datetime.datetime.now() now = time.strftime("%Y-%m-%d %H:%M") originfile = FreeCAD.ActiveDocument.FileName headerNoNumber = "%PM\n" # this line gets no linenumber - if hasattr(job, "Description"): - description = job.Description - else: - description = "" + # if hasattr(job, "Description"): + # description = job.Description + # else: + # description = "" + description = "" # this line gets no linenumber, it is already a specially numbered headerNoNumber += "N9XXX (" + description + ", " + now + ")\n" header = ""