def __init__(self, obj, models, templateFile = None): self.obj = obj 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", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("PathJob","An optional description for this job")) obj.addProperty("App::PropertyString", "CycleTime", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Operations Cycle Time Estimation")) obj.setEditorMode('CycleTime', 1) # read-only obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("PathJob", "For computing Paths; smaller increases accuracy, but slows down computation")) 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.addProperty("App::PropertyBool", "SplitOutput", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob","Split output into multiple gcode files")) obj.addProperty("App::PropertyEnumeration", "OrderOutputBy", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "If multiple WCS, order the output this way")) obj.addProperty("App::PropertyStringList", "Fixtures", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "The Work Coordinate Systems for the Job")) obj.OrderOutputBy = ['Fixture', 'Tool', 'Operation'] obj.Fixtures = ['G54'] 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") if ops.ViewObject: ops.ViewObject.Proxy = 0 ops.ViewObject.Visibility = False obj.Operations = ops obj.setEditorMode('Operations', 2) # hide obj.setEditorMode('Placement', 2) self.setupSetupSheet(obj) self.setupBaseModel(obj, models) self.tooltip = None self.tooltipArgs = None 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 setupStock(self, obj): """setupStock(obj)... setup the Stock for the Job object.""" 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, models, templateFile = None): self.obj = obj 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", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("PathJob","An optional description for this job")) obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("PathJob", "For computing Paths; smaller increases accuracy, but slows down computation")) 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.addProperty("App::PropertyBool", "SplitOutput", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob","Split output into multiple gcode files")) obj.addProperty("App::PropertyEnumeration", "OrderOutputBy", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "If multiple WCS, order the output this way")) obj.addProperty("App::PropertyStringList", "Fixtures", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "The Work Coordinate Systems for the Job")) obj.OrderOutputBy = ['Fixture', 'Tool', 'Operation'] obj.Fixtures = ['G54'] 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") if ops.ViewObject: ops.ViewObject.Proxy = 0 ops.ViewObject.Visibility = False obj.Operations = ops obj.setEditorMode('Operations', 2) # hide obj.setEditorMode('Placement', 2) self.setupSetupSheet(obj) self.setupBaseModel(obj, models) 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, 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") if ops.ViewObject: ops.ViewObject.Proxy = 0 ops.ViewObject.Visibility = False 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 loadStockSettings(self): stock = PathPreferences.defaultStockTemplate() index = -1 if stock: attrs = json.loads(stock) if attrs.get('version') and 1 == int(attrs['version']): stockType = attrs.get('create') if stockType == PathStock.StockType.FromBase: index = 2 elif stockType == PathStock.StockType.CreateBox: index = 0 elif stockType == PathStock.StockType.CreateCylinder: index = 1 else: index = -1 if -1 == index: attrs = {} self.form.stockGroup.setChecked(False) else: self.form.stockGroup.setChecked(True) self.form.stock.setCurrentIndex(index) # this either sets the default value or the value from the template for each field self.form.stockExtXneg.setText(attrs.get('xneg', '1 mm')) self.form.stockExtXpos.setText(attrs.get('xpos', '1 mm')) self.form.stockExtYneg.setText(attrs.get('yneg', '1 mm')) self.form.stockExtYpos.setText(attrs.get('ypos', '1 mm')) self.form.stockExtZneg.setText(attrs.get('zneg', '1 mm')) self.form.stockExtZpos.setText(attrs.get('zpos', '1 mm')) self.form.stockBoxLength.setText(attrs.get('length', '10 mm')) self.form.stockBoxWidth.setText(attrs.get('width', '10 mm')) self.form.stockBoxHeight.setText(attrs.get('height', '10 mm')) self.form.stockCylinderRadius.setText(attrs.get('radius', '5 mm')) self.form.stockCylinderHeight.setText(attrs.get('height', '10 mm')) posX = attrs.get('posX') posY = attrs.get('posY') posZ = attrs.get('posZ') rotX = attrs.get('rotX') rotY = attrs.get('rotY') rotZ = attrs.get('rotZ') rotW = attrs.get('rotW') if posX is not None and posY is not None and posZ is not None and rotX is not None and rotY is not None and rotZ is not None and rotW is not None: pos = FreeCAD.Vector(float(posX), float(posY), float(posZ)) rot = FreeCAD.Rotation(float(rotX), float(rotY), float(rotZ), float(rotW)) placement = FreeCAD.Placement(pos, rot) self.form.stockPlacementGroup.setChecked(True) else: placement = FreeCAD.Placement() self.form.stockPlacementGroup.setChecked(False) self.form.stockAngle.setText( FreeCAD.Units.Quantity("%f rad" % placement.Rotation.Angle).UserString) self.form.stockAxisX.setValue(placement.Rotation.Axis.x) self.form.stockAxisY.setValue(placement.Rotation.Axis.y) self.form.stockAxisZ.setValue(placement.Rotation.Axis.z) self.form.stockPositionX.setText( FreeCAD.Units.Quantity(placement.Base.x, FreeCAD.Units.Length).UserString) self.form.stockPositionY.setText( FreeCAD.Units.Quantity(placement.Base.y, FreeCAD.Units.Length).UserString) self.form.stockPositionZ.setText( FreeCAD.Units.Quantity(placement.Base.z, FreeCAD.Units.Length).UserString) self.setupStock(index) self.form.stock.currentIndexChanged.connect(self.setupStock)
def loadStockSettings(self): stock = PathPreferences.defaultStockTemplate() index = -1 if stock: attrs = json.loads(stock) if attrs.get('version') and 1 == int(attrs['version']): stockType = attrs.get('create') if stockType == PathStock.StockType.FromBase: index = 2 elif stockType == PathStock.StockType.CreateBox: index = 0 elif stockType == PathStock.StockType.CreateCylinder: index = 1 else: index = -1 if -1 == index: attrs = {} self.form.stockGroup.setChecked(False) else: self.form.stockGroup.setChecked(True) self.form.stock.setCurrentIndex(index) # this either sets the default value or the value from the template for each field self.form.stockExtXneg.setText(attrs.get('xneg', '1 mm')) self.form.stockExtXpos.setText(attrs.get('xpos', '1 mm')) self.form.stockExtYneg.setText(attrs.get('yneg', '1 mm')) self.form.stockExtYpos.setText(attrs.get('ypos', '1 mm')) self.form.stockExtZneg.setText(attrs.get('zneg', '1 mm')) self.form.stockExtZpos.setText(attrs.get('zpos', '1 mm')) self.form.stockBoxLength.setText(attrs.get('length', '10 mm')) self.form.stockBoxWidth.setText(attrs.get('width', '10 mm')) self.form.stockBoxHeight.setText(attrs.get('height', '10 mm')) self.form.stockCylinderRadius.setText(attrs.get('radius', '5 mm')) self.form.stockCylinderHeight.setText(attrs.get('height', '10 mm')) posX = attrs.get('posX') posY = attrs.get('posY') posZ = attrs.get('posZ') rotX = attrs.get('rotX') rotY = attrs.get('rotY') rotZ = attrs.get('rotZ') rotW = attrs.get('rotW') if posX is not None and posY is not None and posZ is not None and rotX is not None and rotY is not None and rotZ is not None and rotW is not None: pos = FreeCAD.Vector(float(posX), float(posY), float(posZ)) rot = FreeCAD.Rotation(float(rotX), float(rotY), float(rotZ), float(rotW)) placement = FreeCAD.Placement(pos, rot) self.form.stockPlacementGroup.setChecked(True) else: placement = FreeCAD.Placement() self.form.stockPlacementGroup.setChecked(False) self.form.stockAngle.setText(FreeCAD.Units.Quantity("%f rad" % placement.Rotation.Angle).UserString) self.form.stockAxisX.setValue(placement.Rotation.Axis.x) self.form.stockAxisY.setValue(placement.Rotation.Axis.y) self.form.stockAxisZ.setValue(placement.Rotation.Axis.z) self.form.stockPositionX.setText(FreeCAD.Units.Quantity(placement.Base.x, FreeCAD.Units.Length).UserString) self.form.stockPositionY.setText(FreeCAD.Units.Quantity(placement.Base.y, FreeCAD.Units.Length).UserString) self.form.stockPositionZ.setText(FreeCAD.Units.Quantity(placement.Base.z, FreeCAD.Units.Length).UserString) self.setupStock(index) self.form.stock.currentIndexChanged.connect(self.setupStock)