Skip to content

Commit

Permalink
Merge pull request #3937 from sliptonic/feature/setupreport
Browse files Browse the repository at this point in the history
Path Feature:  Setup Report
  • Loading branch information
sliptonic committed Oct 7, 2020
2 parents d06d568 + c42149b commit 1816a71
Show file tree
Hide file tree
Showing 4 changed files with 675 additions and 123 deletions.
14 changes: 9 additions & 5 deletions src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -32,14 +32,14 @@
import PathScripts.PathUtil as PathUtil
import json
import time
from PathScripts.PathPostProcessor import PostProcessor
from PySide import QtCore

# lazily loaded modules
from lazy_loader.lazy_loader import LazyLoader
ArchPanel = LazyLoader('ArchPanel', globals(), 'ArchPanel')
Draft = LazyLoader('Draft', globals(), 'Draft')

from PathScripts.PathPostProcessor import PostProcessor
from PySide import QtCore

PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())

Expand Down Expand Up @@ -103,6 +103,10 @@ def __init__(self, obj, models, templateFile=None):
obj.addProperty("App::PropertyFile", "PostProcessorOutputFile", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "The NC output file for this project"))
obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Select the Post Processor"))
obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Arguments for the Post Processor (specific to the script)"))
obj.addProperty("App::PropertyString", "LastPostProcessDate", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Last Time the Job was post-processed"))
obj.setEditorMode('LastPostProcessDate', 2) # Hide
obj.addProperty("App::PropertyString", "LastPostProcessOutput", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Last Time the Job was post-processed"))
obj.setEditorMode('LastPostProcessOutput', 2) # Hide

obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("PathJob", "An optional description for this job"))
obj.addProperty("App::PropertyString", "CycleTime", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Job Cycle Time Estimation"))
Expand Down Expand Up @@ -226,7 +230,7 @@ def onDelete(self, obj, arg2=None):
# Tool controllers might refer to either legacy tool or toolbit
PathLog.debug('taking down tool controller')
for tc in obj.ToolController:
if hasattr(tc.Tool,"Proxy"):
if hasattr(tc.Tool, "Proxy"):
PathUtil.clearExpressionEngine(tc.Tool)
doc.removeObject(tc.Tool.Name)
PathUtil.clearExpressionEngine(tc)
Expand Down Expand Up @@ -378,7 +382,7 @@ def getCycleTime(self):
try:
# Convert the formatted time from HH:MM:SS to just seconds
opCycleTime = sum(x * int(t) for x, t in zip([1, 60, 3600], reversed(formattedCycleTime.split(":"))))
except:
except Exception:
continue

if opCycleTime > 0:
Expand Down Expand Up @@ -457,7 +461,7 @@ def Instances():
def Create(name, base, templateFile=None):
'''Create(name, base, templateFile=None) ... creates a new job and all it's resources.
If a template file is specified the new job is initialized with the values from the template.'''
if str == type(base[0]):
if isinstance(base[0], str):
models = []
for baseName in base:
models.append(FreeCAD.ActiveDocument.getObject(baseName))
Expand Down
15 changes: 10 additions & 5 deletions src/Mod/Path/PathScripts/PathPost.py
Expand Up @@ -37,7 +37,7 @@

from PathScripts.PathPostProcessor import PostProcessor
from PySide import QtCore, QtGui

from datetime import datetime

LOG_MODULE = PathLog.thisModule()

Expand Down Expand Up @@ -210,9 +210,9 @@ def exportObjectsWith(self, objs, job, needFilename=True):
print("post: %s(%s, %s)" % (postname, filename, postArgs))
processor = PostProcessor.load(postname)
gcode = processor.export(objs, filename, postArgs)
return (False, gcode)
return (False, gcode, filename)
else:
return (True, '')
return (True, '', filename)

def Activated(self):
PathLog.track()
Expand Down Expand Up @@ -391,17 +391,22 @@ def Activated(self):
rc = '' # pylint: disable=unused-variable
if split:
for slist in postlist:
(fail, rc) = self.exportObjectsWith(slist, job)
(fail, rc, filename) = self.exportObjectsWith(slist, job)
else:
finalpostlist = [item for slist in postlist for item in slist]
(fail, rc) = self.exportObjectsWith(finalpostlist, job)
(fail, rc, filename) = self.exportObjectsWith(finalpostlist, job)

self.subpart = 1

if fail:
FreeCAD.ActiveDocument.abortTransaction()
else:
if hasattr(job, "LastPostProcessDate"):
job.LastPostProcessDate = str(datetime.now())
if hasattr(job, "LastPostProcessOutput"):
job.LastPostProcessOutput = filename
FreeCAD.ActiveDocument.commitTransaction()

FreeCAD.ActiveDocument.recompute()


Expand Down

0 comments on commit 1816a71

Please sign in to comment.