def __init__(self, obj): obj.addProperty("App::PropertyFile", "PostProcessorOutputFile", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.PostProcessorOutputFile = PathPreferences.defaultOutputFile() obj.setEditorMode("PostProcessorOutputFile", 0) # set to default mode obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor")) obj.PostProcessor = postProcessors = PathPreferences.allEnabledPostProcessors() defaultPostProcessor = PathPreferences.defaultPostProcessor() # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed) if defaultPostProcessor in postProcessors: obj.PostProcessor = defaultPostProcessor else: obj.PostProcessor = postProcessors[0] obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs() obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job")) obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation")) obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance() obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations") obj.Proxy = self if FreeCAD.GuiUp: ViewProviderJob(obj.ViewObject)
def loadSettings(self): self.form.leDefaultFilePath.setText(PathPreferences.defaultFilePath()) self.form.leDefaultJobTemplate.setText(PathPreferences.defaultJobTemplate()) blacklist = PathPreferences.postProcessorBlacklist() for processor in PathPreferences.allAvailablePostProcessors(): item = QtGui.QListWidgetItem(processor) if processor in blacklist: item.setCheckState(QtCore.Qt.CheckState.Unchecked) else: item.setCheckState(QtCore.Qt.CheckState.Checked) item.setFlags( QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable) self.form.postProcessorList.addItem(item) self.verifyAndUpdateDefaultPostProcessorWith(PathPreferences.defaultPostProcessor()) self.form.defaultPostProcessorArgs.setText(PathPreferences.defaultPostProcessorArgs()) geomTol = Units.Quantity(PathPreferences.defaultGeometryTolerance(), Units.Length) self.form.geometryTolerance.setText(geomTol.UserString) self.form.leOutputFile.setText(PathPreferences.defaultOutputFile()) self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy()) self.form.tbDefaultFilePath.clicked.connect(self.browseDefaultFilePath) self.form.tbDefaultJobTemplate.clicked.connect(self.browseDefaultJobTemplate) self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip) self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor) self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip) self.form.tbOutputFile.clicked.connect(self.browseOutputFile) self.loadStockSettings()
def loadSettings(self): blacklist = PathPreferences.postProcessorBlacklist() for processor in PathPreferences.allAvailablePostProcessors(): item = QtGui.QListWidgetItem(processor) if processor in blacklist: item.setCheckState(QtCore.Qt.CheckState.Unchecked) else: item.setCheckState(QtCore.Qt.CheckState.Checked) item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable) self.form.postProcessorList.addItem(item) self.verifyAndUpdateDefaultPostProcessorWith( PathPreferences.defaultPostProcessor()) self.form.defaultPostProcessorArgs.setText( PathPreferences.defaultPostProcessorArgs()) geomTol = Units.Quantity(PathPreferences.defaultGeometryTolerance(), Units.Length) self.form.geometryTolerance.setText(geomTol.UserString) self.form.leOutputFile.setText(PathPreferences.defaultOutputFile()) self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy()) self.form.postProcessorList.itemEntered.connect( self.setProcessorListTooltip) self.form.postProcessorList.itemChanged.connect( self.verifyAndUpdateDefaultPostProcessor) self.form.defaultPostProcessor.currentIndexChanged.connect( self.updateDefaultPostProcessorToolTip) self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)
def __init__(self, obj): # obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project") obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.OutputFile = PathPreferences.defaultOutputFile() obj.setEditorMode("OutputFile", 0) # set to default mode 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 = PathPreferences.allEnabledPostProcessors(['']) obj.PostProcessor = PathPreferences.defaultPostProcessor() obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs() 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")) obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch")) obj.MachineUnits = ['Metric', 'Inch'] obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations") obj.Proxy = self if FreeCAD.GuiUp: ViewProviderJob(obj.ViewObject)
def __init__(self, obj): # obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project") obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.OutputFile = PathPreferences.defaultOutputFile() obj.setEditorMode("OutputFile", 0) # set to default mode 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 = PathPreferences.allEnabledPostProcessors(['']) obj.PostProcessor = PathPreferences.defaultPostProcessor() obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs() 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")) obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch")) obj.MachineUnits = ['Metric', 'Inch'] obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations") obj.Proxy = self if FreeCAD.GuiUp: ViewProviderJob(obj.ViewObject)
def resolveFileName(self, job): path = PathPreferences.defaultOutputFile() if job.PostProcessorOutputFile: path = job.PostProcessorOutputFile filename = path if '%D' in filename: D = FreeCAD.ActiveDocument.FileName if D: D = os.path.dirname(D) # in case the document is in the current working directory if not D: D = '.' else: FreeCAD.Console.PrintError("Please save document in order to resolve output path!\n") return None filename = filename.replace('%D', D) if '%d' in filename: d = FreeCAD.ActiveDocument.Label filename = filename.replace('%d', d) if '%j' in filename: j = job.Label filename = filename.replace('%j', j) if '%M' in filename: pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir()) filename = filename.replace('%M', M) policy = PathPreferences.defaultOutputPolicy() openDialog = policy == 'Open File Dialog' if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)): # Either the entire filename resolves into a directory or the parent directory doesn't exist. # Either way I don't know what to do - ask for help openDialog = True if os.path.isfile(filename) and not openDialog: if policy == 'Open File Dialog on conflict': openDialog = True elif policy == 'Append Unique ID on conflict': fn, ext = os.path.splitext(filename) nr = fn[-3:] n = 1 if nr.isdigit(): n = int(nr) while os.path.isfile("%s%03d%s" % (fn, n, ext)): n = n + 1 filename = "%s%03d%s" % (fn, n, ext) if openDialog: foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), "Output File", filename) if foo: filename = foo[0] else: filename = None return filename
def resolveFileName(self, job): path = PathPreferences.defaultOutputFile() if job.OutputFile: path = job.OutputFile filename = path if '%D' in filename: D = FreeCAD.ActiveDocument.FileName if D: D = os.path.dirname(D) else: FreeCAD.Console.PrintError( "Please save document in order to resolve output path!\n") return None filename = filename.replace('%D', D) if '%d' in filename: d = FreeCAD.ActiveDocument.Label filename = filename.replace('%d', d) if '%j' in filename: j = job.Label filename = filename.replace('%j', j) if '%M' in filename: pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir()) filename = filename.replace('%M', M) policy = PathPreferences.defaultOutputPolicy() openDialog = policy == 'Open File Dialog' if os.path.isdir(filename) or not os.path.isdir( os.path.dirname(filename)): # Either the entire filename resolves into a directory or the parent directory doesn't exist. # Either way I don't know what to do - ask for help openDialog = True if os.path.isfile(filename) and not openDialog: if policy == 'Open File Dialog on conflict': openDialog = True elif policy == 'Append Unique ID on conflict': fn, ext = os.path.splitext(filename) nr = fn[-3:] n = 1 if nr.isdigit(): n = int(nr) while os.path.isfile("%s%03d%s" % (fn, n, ext)): n = n + 1 filename = "%s%03d%s" % (fn, n, ext) if openDialog: foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), "Output File", filename) if foo: filename = foo[0] else: filename = None return filename
def resolveFileName(self, job): # print("resolveFileName(%s)" % job.Label) path = PathPreferences.defaultOutputFile() if job.OutputFile: path = job.OutputFile filename = path if "%D" in filename: D = FreeCAD.ActiveDocument.FileName if D: D = os.path.dirname(D) else: FreeCAD.Console.PrintError("Please save document in order to resolve output path!\n") return None filename = filename.replace("%D", D) if "%d" in filename: d = FreeCAD.ActiveDocument.Label filename = filename.replace("%d", d) if "%j" in filename: j = job.Label filename = filename.replace("%j", j) if "%M" in filename: pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir()) filename = filename.replace("%M", M) policy = PathPreferences.defaultOutputPolicy() openDialog = policy == "Open File Dialog" if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)): # Either the entire filename resolves into a directory or the parent directory doesn't exist. # Either way I don't know what to do - ask for help openDialog = True if os.path.isfile(filename) and not openDialog: if policy == "Open File Dialog on conflict": openDialog = True elif policy == "Append Unique ID on conflict": fn, ext = os.path.splitext(filename) nr = fn[-3:] n = 1 if nr.isdigit(): n = int(nr) while os.path.isfile("%s%03d%s" % (fn, n, ext)): n = n + 1 filename = "%s%03d%s" % (fn, n, ext) if openDialog: foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), "Output File", filename) if foo: filename = foo[0] else: filename = None # print("resolveFileName(%s, %s) -> '%s'" % (path, policy, filename)) return filename
def __init__(self, obj, base, templateFile = None): self.obj = obj obj.addProperty("App::PropertyFile", "PostProcessorOutputFile", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor")) obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job")) obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation")) obj.addProperty("App::PropertyLink", "Base", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "The base object for all operations")) obj.addProperty("App::PropertyLink", "Stock", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Solid object to be used as stock.")) obj.addProperty("App::PropertyLink", "Operations", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Compound path of all operations in the order they are processed.")) obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job.")) obj.PostProcessorOutputFile = PathPreferences.defaultOutputFile() #obj.setEditorMode("PostProcessorOutputFile", 0) # set to default mode obj.PostProcessor = postProcessors = PathPreferences.allEnabledPostProcessors() defaultPostProcessor = PathPreferences.defaultPostProcessor() # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed) if defaultPostProcessor in postProcessors: obj.PostProcessor = defaultPostProcessor else: obj.PostProcessor = postProcessors[0] obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs() obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance() ops = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Operations") obj.Operations = ops obj.setEditorMode('Operations', 2) # hide obj.setEditorMode('Placement', 2) self.setupSetupSheet(obj) obj.Base = createResourceClone(obj, base, 'Base', 'BaseGeometry') obj.Proxy = self self.setFromTemplateFile(obj, templateFile) if not obj.Stock: stockTemplate = PathPreferences.defaultStockTemplate() if stockTemplate: obj.Stock = PathStock.CreateFromTemplate(obj, json.loads(stockTemplate)) if not obj.Stock: obj.Stock = PathStock.CreateFromBase(obj) if obj.Stock.ViewObject: obj.Stock.ViewObject.Visibility = False
def __init__(self, obj): # obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project") obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.OutputFile = PathPreferences.defaultOutputFile() obj.setEditorMode("OutputFile", 0) # set to default mode 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 = postProcessors = PathPreferences.allEnabledPostProcessors() defaultPostProcessor = PathPreferences.defaultPostProcessor() # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed) if defaultPostProcessor in postProcessors: obj.PostProcessor = defaultPostProcessor else: obj.PostProcessor = postProcessors[0] obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs() 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")) obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch")) obj.MachineUnits = ['Metric', 'Inch'] obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation")) obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance() obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations") obj.Proxy = self if FreeCAD.GuiUp: ViewProviderJob(obj.ViewObject)
def loadSettings(self): blacklist = PathPreferences.postProcessorBlacklist() for processor in PathPreferences.allAvailablePostProcessors(): item = QtGui.QListWidgetItem(processor) if processor in blacklist: item.setCheckState(QtCore.Qt.CheckState.Unchecked) else: item.setCheckState(QtCore.Qt.CheckState.Checked) item.setFlags( QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable) self.form.postProcessorList.addItem(item) self.verifyAndUpdateDefaultPostProcessorWith(PathPreferences.defaultPostProcessor()) self.form.defaultPostProcessorArgs.setText(PathPreferences.defaultPostProcessorArgs()) self.form.leOutputFile.setText(PathPreferences.defaultOutputFile()) self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy()) self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip) self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor) self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip) self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)