Skip to content

Commit

Permalink
Merge pull request #365 from danielfalck/pppathfix
Browse files Browse the repository at this point in the history
fix for not being able to use the post code icon
  • Loading branch information
wwmayer committed Dec 5, 2016
2 parents 7a32aed + 2e44b6c commit d26b0fa
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/Mod/Path/PathScripts/PathPost.py
Expand Up @@ -162,6 +162,28 @@ def IsActive(self):
return True
return False

def exportObjectsWith(self, objs, job, needFilename = True):
# check if the user has a project and has set the default post and
# output filename
postArgs = PathPreferences.defaultPostProcessorArgs()
if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
postArgs = job.PostProcessorArgs
elif hasattr(job, "PostProcessor") and job.PostProcessor:
postArgs = ''

postname = self.resolvePostProcessor(job)
filename = '-'
if postname and needFilename:
filename = self.resolveFileName(job)

if postname and filename:
print("post: %s(%s, %s)" % (postname, filename, postArgs))
processor = PostProcessor.load(postname)
gcode = processor.export(objs, filename, postArgs)
return (False, gcode)
else:
return (True, '')

def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Post", "Post Process the Selected path(s)"))
Expand All @@ -187,35 +209,15 @@ def Activated(self):
else:
job = jobs.pop()
print("Job for selected objects = %s" % job.Name)
(fail, rc) = exportObjectsWith(selected, job)
(fail, rc) = self.exportObjectsWith(selected, job)

if fail:
FreeCAD.ActiveDocument.abortTransaction()
else:
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

def exportObjectsWith(self, objs, job, needFilename = True):
# check if the user has a project and has set the default post and
# output filename
postArgs = PathPreferences.defaultPostProcessorArgs()
if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
postArgs = job.PostProcessorArgs
elif hasattr(job, "PostProcessor") and job.PostProcessor:
postArgs = ''

postname = self.resolvePostProcessor(job)
filename = '-'
if postname and needFilename:
filename = self.resolveFileName(job)

if postname and filename:
print("post: %s(%s, %s)" % (postname, filename, postArgs))
processor = PostProcessor.load(postname)
gcode = processor.export(objs, filename, postArgs)
return (False, gcode)
else:
return (True, '')

if FreeCAD.GuiUp:
# register the FreeCAD command
Expand Down

0 comments on commit d26b0fa

Please sign in to comment.