diff --git a/src/Mod/Path/Gui/Resources/panels/JobEdit.ui b/src/Mod/Path/Gui/Resources/panels/JobEdit.ui index 3ce69ac98..76180f9cb 100644 --- a/src/Mod/Path/Gui/Resources/panels/JobEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/JobEdit.ui @@ -35,15 +35,15 @@ - 0 + 2 0 0 - 378 - 409 + 363 + 443 @@ -145,8 +145,8 @@ 0 0 - 451 - 349 + 378 + 391 @@ -215,8 +215,8 @@ 0 0 - 451 - 349 + 378 + 391 @@ -273,6 +273,20 @@ + + + + Post Processor Arguments + + + + + + + <html><head/><body><p>Optional arguments passed to the Post Processor. The arguments are specific for each Post Processor, please see it's documentation for details.</p></body></html> + + + diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index 9c98be775..de9e70053 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -68,6 +68,8 @@ class ObjectPathJob: obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job")) obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor")) obj.PostProcessor = allposts + obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) + obj.PostProcessorArgs = "" obj.addProperty("App::PropertyString", "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program")) obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program")) @@ -263,6 +265,8 @@ class TaskPanel: if self.obj: if hasattr(self.obj, "PostProcessor"): self.obj.PostProcessor = str(self.form.cboPostProcessor.currentText()) + if hasattr(self.obj, "PostProcessorArgs"): + self.obj.PostProcessorArgs = str(self.form.cboPostProcessorArgs.displayText) if hasattr(self.obj, "Label"): self.obj.Label = str(self.form.leLabel.text()) if hasattr(self.obj, "OutputFile"): @@ -298,6 +302,7 @@ class TaskPanel: self.form.cboPostProcessor.blockSignals(True) self.form.cboPostProcessor.setCurrentIndex(postindex) self.form.cboPostProcessor.blockSignals(False) + self.form.cboPostProcessorArgs.displayText = self.obj.PostProcessorArgs for child in self.obj.Group: self.form.PathsList.addItem(child.Name) diff --git a/src/Mod/Path/PathScripts/PathPost.py b/src/Mod/Path/PathScripts/PathPost.py index f1f556587..0d1fd1d25 100644 --- a/src/Mod/Path/PathScripts/PathPost.py +++ b/src/Mod/Path/PathScripts/PathPost.py @@ -65,6 +65,7 @@ class CommandPathPost: # default to the dumper post and default .tap file postname = "dumper" filename = "tmp.tap" + postArgs = "" print "in activated %s" %(obj) @@ -90,11 +91,13 @@ class CommandPathPost: if proj.OutputFile: filename = proj.OutputFile + if hasattr(postobj, "PostProcessorArgs"): + postArgs = postobj.PostProcessorArgs postname += "_post" exec "import %s as current_post" % postname reload(current_post) - current_post.export(obj, filename) + current_post.export(obj, filename, postArgs) FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/Path/PathScripts/centroid_post.py b/src/Mod/Path/PathScripts/centroid_post.py index d8acd9b86..89f3193d1 100644 --- a/src/Mod/Path/PathScripts/centroid_post.py +++ b/src/Mod/Path/PathScripts/centroid_post.py @@ -69,7 +69,7 @@ FOOTER = 'M99'+'\n' if open.__module__ == '__builtin__': pythonopen = open -def export(selection,filename): +def export(selection,filename,argstring): params = ['X','Y','Z','A','B','I','J','F','H','S','T','Q','R','L'] #Using XY plane most of the time so skipping K for obj in selection: if not hasattr(obj,"Path"): diff --git a/src/Mod/Path/PathScripts/comparams_post.py b/src/Mod/Path/PathScripts/comparams_post.py index bd0fb4fcc..91a72cb5d 100644 --- a/src/Mod/Path/PathScripts/comparams_post.py +++ b/src/Mod/Path/PathScripts/comparams_post.py @@ -71,7 +71,7 @@ def lineout(command, oldvals, modal): line += "F"+str(ffmt(command.Parameters['F'])) return line -def export(obj,filename): +def export(obj,filename,argstring): modal=True commands = obj[0] gcode = '' diff --git a/src/Mod/Path/PathScripts/dumper_post.py b/src/Mod/Path/PathScripts/dumper_post.py index c2dfea583..87e33ec3e 100644 --- a/src/Mod/Path/PathScripts/dumper_post.py +++ b/src/Mod/Path/PathScripts/dumper_post.py @@ -39,7 +39,7 @@ if open.__module__ == '__builtin__': pythonopen = open -def export(objectslist, filename): +def export(objectslist, filename,argstring): output = '''(This ouput produced with the dump post processor) (Dump is useful for inspecting the raw commands in your paths) (but is not useful for driving machines.) diff --git a/src/Mod/Path/PathScripts/example_post.py b/src/Mod/Path/PathScripts/example_post.py index cd482c145..a14dbda04 100644 --- a/src/Mod/Path/PathScripts/example_post.py +++ b/src/Mod/Path/PathScripts/example_post.py @@ -39,7 +39,7 @@ if open.__module__ == '__builtin__': pythonopen = open -def export(objectslist, filename): +def export(objectslist, filename,argstring): "called when freecad exports a list of objects" if len(objectslist) > 1: print "This script is unable to write more than one Path object" diff --git a/src/Mod/Path/PathScripts/linuxcnc_post.py b/src/Mod/Path/PathScripts/linuxcnc_post.py index c4812a9c4..9c7ada7fb 100644 --- a/src/Mod/Path/PathScripts/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/linuxcnc_post.py @@ -79,8 +79,26 @@ TOOL_CHANGE = '''''' if open.__module__ == '__builtin__': pythonopen = open +def processArguments(argstring): + global OUTPUT_HEADER + global OUTPUT_COMMENTS + global OUTPUT_LINE_NUMBERS + for arg in argstring.split(): + if arg == '--header': + OUTPUT_HEADER = True + elif arg == '--no-header': + OUTPUT_HEADER = False + elif arg == '--comments': + OUTPUT_COMMENTS = True + elif arg == '--no-comments': + OUTPUT_COMMENTS = False + elif arg == '--line-numbers': + OUTPUT_LINE_NUMBERS = True + elif arg == '--no-line-numbers': + OUTPUT_LINE_NUMBERS = False -def export(objectslist, filename): +def export(objectslist, filename, argstring): + processArguments(argstring) global UNITS for obj in objectslist: if not hasattr(obj, "Path"): @@ -168,7 +186,6 @@ def linenumber(): return "N" + str(LINENR) + " " return "" - def parse(pathobj): out = "" lastcommand = None diff --git a/src/Mod/Path/PathScripts/opensbp_post.py b/src/Mod/Path/PathScripts/opensbp_post.py index 38e9b203b..25969734a 100644 --- a/src/Mod/Path/PathScripts/opensbp_post.py +++ b/src/Mod/Path/PathScripts/opensbp_post.py @@ -74,7 +74,7 @@ if open.__module__ == '__builtin__': CurrentState = {} -def export(objectslist, filename): +def export(objectslist, filename, argstring): global CurrentState for obj in objectslist: diff --git a/src/Mod/Path/PathScripts/rml_post.py b/src/Mod/Path/PathScripts/rml_post.py index ac40fe1f3..0c3b30ef2 100644 --- a/src/Mod/Path/PathScripts/rml_post.py +++ b/src/Mod/Path/PathScripts/rml_post.py @@ -44,7 +44,7 @@ if open.__module__ == '__builtin__': # Entrypoint used by FreeCAD -def export(objectslist, filename): +def export(objectslist, filename, argstring): "Export objects as Roland Modela code." code = ""