Added argument support for post processors - examples in linuxcnc_post.py.
This commit is contained in:
parent
84161038c2
commit
da94fb506a
|
@ -35,15 +35,15 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="General">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>378</width>
|
||||
<height>409</height>
|
||||
<width>363</width>
|
||||
<height>443</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
|
@ -145,8 +145,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>451</width>
|
||||
<height>349</height>
|
||||
<width>378</width>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
|
@ -215,8 +215,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>451</width>
|
||||
<height>349</height>
|
||||
<width>378</width>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
|
@ -273,6 +273,20 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="cboPostProcessor"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Post Processor Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="cboPostProcessorArgs">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"):
|
||||
|
|
|
@ -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 = ''
|
||||
|
|
|
@ -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.)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -74,7 +74,7 @@ if open.__module__ == '__builtin__':
|
|||
CurrentState = {}
|
||||
|
||||
|
||||
def export(objectslist, filename):
|
||||
def export(objectslist, filename, argstring):
|
||||
global CurrentState
|
||||
|
||||
for obj in objectslist:
|
||||
|
|
|
@ -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 = ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user