예제 #1
0
 def Execute(cls, job, path, dialog=None):
     root = xml.Element('PathJobTemplate')
     jobAttributes = job.Proxy.templateAttrs(job)
     if dialog and not dialog.includePostProcessing():
         jobAttributes.pop(PathJob.JobTemplate.PostProcessor, None)
         jobAttributes.pob(PathJob.JobTemplate.PostProcessorArgs, None)
         jobAttributes.pob(PathJob.JobTemplate.PostProcessorOutputFile,
                           None)
     xml.SubElement(root, PathJob.JobTemplate.Job, jobAttributes)
     tcs = dialog.includeToolControllers() if dialog else job.ToolController
     for tc in tcs:
         element = xml.SubElement(root, PathJob.JobTemplate.ToolController,
                                  tc.Proxy.templateAttrs(tc))
         element.append(xml.fromstring(tc.Tool.Content))
     if dialog:
         if dialog.includeStock():
             xml.SubElement(
                 root, PathJob.JobTemplate.Stock,
                 PathStock.TemplateAttributes(
                     job.Stock, dialog.includeStockExtent(),
                     dialog.includeStockPlacement()))
     else:
         xml.SubElement(root, PathJob.JobTemplate.Stock,
                        PathStock.TemplateAttributes(job.Stock))
     xml.ElementTree(root).write(path)
예제 #2
0
    def test00(self):
        """Test CreateBox"""

        stock = PathStock.CreateBox(self.job)
        self.assertTrue(hasattr(stock, "Length"))
        self.assertTrue(hasattr(stock, "Width"))
        self.assertTrue(hasattr(stock, "Height"))
        self.assertEqual(100, stock.Length)
        self.assertEqual(200, stock.Width)
        self.assertEqual(300, stock.Height)

        extent = FreeCAD.Vector(17, 13, 77)
        stock = PathStock.CreateBox(self.job, extent)
        self.assertEqual(17, stock.Length)
        self.assertEqual(13, stock.Width)
        self.assertEqual(77, stock.Height)

        placement = FreeCAD.Placement(
            FreeCAD.Vector(-3, 88, 4), FreeCAD.Vector(0, 0, 1), 180
        )
        stock = PathStock.CreateBox(self.job, extent, placement)
        self.assertEqual(17, stock.Length)
        self.assertEqual(13, stock.Width)
        self.assertEqual(77, stock.Height)
        self.assertPlacement(placement, stock.Placement)
예제 #3
0
    def test12(self):
        '''Verify FromTemplate from Base creation.'''
        neg = FreeCAD.Vector(1, 2, 3)
        pos = FreeCAD.Vector(9, 8, 7)
        orig = PathStock.CreateFromBase(self.job, neg, pos)

        # Make sure we have a different base object for the creation
        self.base.Length = 11
        self.base.Width = 12
        self.base.Height = 13

        # full template
        template = PathStock.TemplateAttributes(orig)
        stock = PathStock.CreateFromTemplate(self.job, template)
        self.assertEqual(PathStock.StockType.FromBase,
                         PathStock.StockType.FromStock(stock))
        self.assertEqual(orig.ExtXneg, stock.ExtXneg)
        self.assertEqual(orig.ExtXpos, stock.ExtXpos)
        self.assertEqual(orig.ExtYneg, stock.ExtYneg)
        self.assertEqual(orig.ExtYpos, stock.ExtYpos)
        self.assertEqual(orig.ExtZneg, stock.ExtZneg)
        self.assertEqual(orig.ExtZpos, stock.ExtZpos)

        bb = stock.Shape.BoundBox
        self.assertEqual(neg.x + pos.x + 11, bb.XLength)
        self.assertEqual(neg.y + pos.y + 12, bb.YLength)
        self.assertEqual(neg.z + pos.z + 13, bb.ZLength)
예제 #4
0
    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
예제 #5
0
 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
예제 #6
0
    def test11(self):
        """Verify FromTemplate cylinder creation."""
        radius = 7
        height = 12
        placement = FreeCAD.Placement(
            FreeCAD.Vector(99, 88, 77), FreeCAD.Vector(1, 1, 1), 123
        )
        orig = PathStock.CreateCylinder(self.job, radius, height, placement)

        # full template
        template = PathStock.TemplateAttributes(orig)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateCylinder, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(orig.Radius, stock.Radius)
        self.assertEqual(orig.Height, stock.Height)
        self.assertPlacement(orig.Placement, stock.Placement)

        # no extent in template
        template = PathStock.TemplateAttributes(orig, False, True)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateCylinder, PathStock.StockType.FromStock(stock)
        )
        self.assertRoughly(R, stock.Radius.Value)
        self.assertEqual(300, stock.Height)
        self.assertPlacement(orig.Placement, stock.Placement)

        # no placement template - and no base
        template = PathStock.TemplateAttributes(orig, True, False)
        stock = PathStock.CreateFromTemplate(None, template)

        self.assertEqual(
            PathStock.StockType.CreateCylinder, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(orig.Radius, stock.Radius)
        self.assertEqual(orig.Height, stock.Height)
        self.assertPlacement(FreeCAD.Placement(), stock.Placement)

        # no placement template - but base
        template = PathStock.TemplateAttributes(orig, True, False)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateCylinder, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(orig.Radius, stock.Radius)
        self.assertEqual(orig.Height, stock.Height)
        self.assertPlacement(
            FreeCAD.Placement(FreeCAD.Vector(50, 100, 0), FreeCAD.Rotation()),
            stock.Placement,
        )
예제 #7
0
    def Execute(cls, job, path, dialog=None):
        attrs = job.Proxy.templateAttrs(job)

        # post processor settings
        if dialog and not dialog.includePostProcessing():
            attrs.pop(PathJob.JobTemplate.PostProcessor, None)
            attrs.pop(PathJob.JobTemplate.PostProcessorArgs, None)
            attrs.pop(PathJob.JobTemplate.PostProcessorOutputFile, None)

        # tool controller settings
        toolControllers = dialog.includeToolControllers(
        ) if dialog else job.Tools.Group
        if toolControllers:
            tcAttrs = [tc.Proxy.templateAttrs(tc) for tc in toolControllers]
            attrs[PathJob.JobTemplate.ToolController] = tcAttrs

        # stock settings
        stockAttrs = None
        if dialog:
            if dialog.includeStock():
                stockAttrs = PathStock.TemplateAttributes(
                    job.Stock,
                    dialog.includeStockExtent(),
                    dialog.includeStockPlacement(),
                )
        else:
            stockAttrs = PathStock.TemplateAttributes(job.Stock)
        if stockAttrs:
            attrs[PathJob.JobTemplate.Stock] = stockAttrs

        # setup sheet
        setupSheetAttrs = None
        if dialog:
            setupSheetAttrs = job.Proxy.setupSheet.templateAttributes(
                dialog.includeSettingToolRapid(),
                dialog.includeSettingCoolant(),
                dialog.includeSettingOperationHeights(),
                dialog.includeSettingOperationDepths(),
                dialog.includeSettingOpsSettings(),
            )
        else:
            setupSheetAttrs = job.Proxy.setupSheet.templateAttributes(
                True, True, True)
        if setupSheetAttrs:
            attrs[PathJob.JobTemplate.SetupSheet] = setupSheetAttrs

        encoded = job.Proxy.setupSheet.encodeTemplateAttributes(attrs)
        # write template
        with open(PathUtil.toUnicode(path), "w") as fp:
            json.dump(encoded, fp, sort_keys=True, indent=2)
예제 #8
0
 def assignTemplate(self, obj, template):
     '''assignTemplate(obj, template) ... extract the properties from the given template file and assign to receiver.
     This will also create any TCs stored in the template.'''
     tcs = []
     if template:
         tree = xml.parse(template)
         for job in tree.getroot().iter(JobTemplate.Job):
             if job.get(JobTemplate.GeometryTolerance):
                 obj.GeometryTolerance = float(
                     job.get(JobTemplate.GeometryTolerance))
             if job.get(JobTemplate.PostProcessor):
                 obj.PostProcessor = job.get(JobTemplate.PostProcessor)
                 if job.get(JobTemplate.PostProcessorArgs):
                     obj.PostProcessorArgs = job.get(
                         JobTemplate.PostProcessorArgs)
                 else:
                     obj.PostProcessorArgs = ''
             if job.get(JobTemplate.PostProcessorOutputFile):
                 obj.PostProcessorOutputFile = job.get(
                     JobTemplate.PostProcessorOutputFile)
             if job.get(JobTemplate.Description):
                 obj.Description = job.get(JobTemplate.Description)
         for tc in tree.getroot().iter(JobTemplate.ToolController):
             tcs.append(PathToolController.FromTemplate(tc))
         for stock in tree.getroot().iter(JobTemplate.Stock):
             obj.Stock = PathStock.CreateFromTemplate(self, stock)
     else:
         tcs.append(PathToolController.Create())
     PathLog.debug("setting tool controllers (%d)" % len(tcs))
     obj.ToolController = tcs
예제 #9
0
    def setFromTemplateFile(self, obj, template):
        """setFromTemplateFile(obj, template) ... extract the properties from the given template file and assign to receiver.
        This will also create any TCs stored in the template."""
        tcs = []
        if template:
            with open(PathUtil.toUnicode(template), "rb") as fp:
                attrs = json.load(fp)

            if attrs.get(JobTemplate.Version) and 1 == int(attrs[JobTemplate.Version]):
                attrs = self.setupSheet.decodeTemplateAttributes(attrs)
                if attrs.get(JobTemplate.SetupSheet):
                    self.setupSheet.setFromTemplate(attrs[JobTemplate.SetupSheet])

                if attrs.get(JobTemplate.GeometryTolerance):
                    obj.GeometryTolerance = float(
                        attrs.get(JobTemplate.GeometryTolerance)
                    )
                if attrs.get(JobTemplate.PostProcessor):
                    obj.PostProcessor = attrs.get(JobTemplate.PostProcessor)
                    if attrs.get(JobTemplate.PostProcessorArgs):
                        obj.PostProcessorArgs = attrs.get(JobTemplate.PostProcessorArgs)
                    else:
                        obj.PostProcessorArgs = ""
                if attrs.get(JobTemplate.PostProcessorOutputFile):
                    obj.PostProcessorOutputFile = attrs.get(
                        JobTemplate.PostProcessorOutputFile
                    )
                if attrs.get(JobTemplate.Description):
                    obj.Description = attrs.get(JobTemplate.Description)

                if attrs.get(JobTemplate.ToolController):
                    for tc in attrs.get(JobTemplate.ToolController):
                        tcs.append(PathToolController.FromTemplate(tc))
                if attrs.get(JobTemplate.Stock):
                    obj.Stock = PathStock.CreateFromTemplate(
                        obj, attrs.get(JobTemplate.Stock)
                    )

                if attrs.get(JobTemplate.Fixtures):
                    obj.Fixtures = [
                        x for y in attrs.get(JobTemplate.Fixtures) for x in y
                    ]

                if attrs.get(JobTemplate.OrderOutputBy):
                    obj.OrderOutputBy = attrs.get(JobTemplate.OrderOutputBy)

                if attrs.get(JobTemplate.SplitOutput):
                    obj.SplitOutput = attrs.get(JobTemplate.SplitOutput)

                PathLog.debug("setting tool controllers (%d)" % len(tcs))
                obj.Tools.Group = tcs
            else:
                PathLog.error(
                    "Unsupported PathJob template version {}".format(
                        attrs.get(JobTemplate.Version)
                    )
                )

        if not tcs:
            self.addToolController(PathToolController.Create())
예제 #10
0
    def __init__(self, obj, base, job):
        obj.addProperty(
            "App::PropertyLink",
            "Base",
            "Base",
            QT_TRANSLATE_NOOP("App::Property", "The base path to modify"),
        )
        obj.Base = base
        obj.addProperty(
            "App::PropertyLink",
            "Stock",
            "Boundary",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "Solid object to be used to limit the generated Path.",
            ),
        )
        obj.Stock = PathStock.CreateFromBase(job)
        obj.addProperty(
            "App::PropertyBool",
            "Inside",
            "Boundary",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "Determines if Boundary describes an inclusion or exclusion mask.",
            ),
        )
        obj.Inside = True

        self.obj = obj
        self.safeHeight = None
        self.clearanceHeight = None
예제 #11
0
    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
예제 #12
0
 def setFields(self, obj):
     if not self.IsStock(obj):
         self.setStock(obj, PathStock.CreateFromBase(obj))
     self.setLengthField(self.form.stockExtXneg, obj.Stock.ExtXneg)
     self.setLengthField(self.form.stockExtXpos, obj.Stock.ExtXpos)
     self.setLengthField(self.form.stockExtYneg, obj.Stock.ExtYneg)
     self.setLengthField(self.form.stockExtYpos, obj.Stock.ExtYpos)
     self.setLengthField(self.form.stockExtZneg, obj.Stock.ExtZneg)
     self.setLengthField(self.form.stockExtZpos, obj.Stock.ExtZpos)
예제 #13
0
    def test01(self):
        '''Test CreateCylinder'''

        stock = PathStock.CreateCylinder(self.job)
        self.assertTrue(hasattr(stock, 'Radius'))
        self.assertTrue(hasattr(stock, 'Height'))
        self.assertRoughly(R, stock.Radius.Value)
        self.assertEqual(300, stock.Height)

        stock = PathStock.CreateCylinder(self.job, 37, 24)
        self.assertEqual(37, stock.Radius)
        self.assertEqual(24, stock.Height)

        placement = FreeCAD.Placement(FreeCAD.Vector(3, 8, -4), FreeCAD.Vector(0, 0, 1), -90)
        stock = PathStock.CreateCylinder(self.job, 1, 88, placement)
        self.assertEqual(1, stock.Radius)
        self.assertEqual(88, stock.Height)
        self.assertPlacement(placement, stock.Placement)
예제 #14
0
 def getFields(self, obj):
     stock = self.form.stockExisting.itemData(
         self.form.stockExisting.currentIndex())
     if not (hasattr(obj.Stock, 'Objects') and len(obj.Stock.Objects) == 1
             and obj.Stock.Objects[0] == stock):
         if stock:
             stock = PathJob.createResourceClone(obj, stock, 'Stock',
                                                 'Stock')
             stock.ViewObject.Visibility = True
             PathStock.SetupStockObject(stock, PathStock.StockType.Unknown)
             stock.Proxy.execute(stock)
             self.setStock(obj, stock)
예제 #15
0
 def Execute(cls, job, path, dialog=None):
     attrs = job.Proxy.templateAttrs(job)
     if dialog and not dialog.includePostProcessing():
         attrs.pop(PathJob.JobTemplate.PostProcessor, None)
         attrs.pob(PathJob.JobTemplate.PostProcessorArgs, None)
         attrs.pob(PathJob.JobTemplate.PostProcessorOutputFile, None)
     toolControllers = dialog.includeToolControllers(
     ) if dialog else job.ToolController
     if toolControllers:
         tcAttrs = [tc.Proxy.templateAttrs(tc) for tc in toolControllers]
         attrs[PathJob.JobTemplate.ToolController] = tcAttrs
     stockAttrs = None
     if dialog:
         if dialog.includeStock():
             stockAttrs = PathStock.TemplateAttributes(
                 job.Stock, dialog.includeStockExtent(),
                 dialog.includeStockPlacement())
     else:
         stockAttrs = PathStock.TemplateAttributes(job.Stock)
     if stockAttrs:
         attrs[PathJob.JobTemplate.Stock] = stockAttrs
     with open(unicode(path), 'wb') as fp:
         json.dump(attrs, fp, sort_keys=True, indent=2)
예제 #16
0
    def setFromTemplateFile(self, obj, template):
        '''setFromTemplateFile(obj, template) ... extract the properties from the given template file and assign to receiver.
        This will also create any TCs stored in the template.'''
        tcs = []
        if template:
            with open(PathUtil.toUnicode(template), 'rb') as fp:
                attrs = json.load(fp)

            if attrs.get(JobTemplate.Version) and 1 == int(
                    attrs[JobTemplate.Version]):
                attrs = self.setupSheet.decodeTemplateAttributes(attrs)
                if attrs.get(JobTemplate.SetupSheet):
                    self.setupSheet.setFromTemplate(
                        attrs[JobTemplate.SetupSheet])

                if attrs.get(JobTemplate.GeometryTolerance):
                    obj.GeometryTolerance = float(
                        attrs.get(JobTemplate.GeometryTolerance))
                if attrs.get(JobTemplate.PostProcessor):
                    obj.PostProcessor = attrs.get(JobTemplate.PostProcessor)
                    if attrs.get(JobTemplate.PostProcessorArgs):
                        obj.PostProcessorArgs = attrs.get(
                            JobTemplate.PostProcessorArgs)
                    else:
                        obj.PostProcessorArgs = ''
                if attrs.get(JobTemplate.PostProcessorOutputFile):
                    obj.PostProcessorOutputFile = attrs.get(
                        JobTemplate.PostProcessorOutputFile)
                if attrs.get(JobTemplate.Description):
                    obj.Description = attrs.get(JobTemplate.Description)

                if attrs.get(JobTemplate.ToolController):
                    for tc in attrs.get(JobTemplate.ToolController):
                        tcs.append(PathToolController.FromTemplate(tc))
                if attrs.get(JobTemplate.Stock):
                    obj.Stock = PathStock.CreateFromTemplate(
                        obj, attrs.get(JobTemplate.Stock))

                PathLog.debug("setting tool controllers (%d)" % len(tcs))
                obj.ToolController = tcs
            else:
                PathLog.error(
                    translate('PathJob',
                              "Unsupported PathJob template version %s") %
                    attrs.get(JobTemplate.Version))
        if not tcs:
            self.addToolController(PathToolController.Create())
예제 #17
0
    def test10(self):
        """Verify FromTemplate box creation."""

        extent = FreeCAD.Vector(17, 13, 77)
        placement = FreeCAD.Placement(
            FreeCAD.Vector(3, 8, -4), FreeCAD.Vector(0, 0, 1), -90
        )
        orig = PathStock.CreateBox(self.job, extent, placement)

        # collect full template
        template = PathStock.TemplateAttributes(orig)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateBox, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(orig.Length, stock.Length)
        self.assertEqual(orig.Width, stock.Width)
        self.assertEqual(orig.Height, stock.Height)
        self.assertPlacement(orig.Placement, stock.Placement)

        # don't store extent in template
        template = PathStock.TemplateAttributes(orig, False, True)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateBox, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(100, stock.Length)
        self.assertEqual(200, stock.Width)
        self.assertEqual(300, stock.Height)
        self.assertPlacement(orig.Placement, stock.Placement)

        # don't store placement in template
        template = PathStock.TemplateAttributes(orig, True, False)
        stock = PathStock.CreateFromTemplate(self.job, template)

        self.assertEqual(
            PathStock.StockType.CreateBox, PathStock.StockType.FromStock(stock)
        )
        self.assertEqual(orig.Length, stock.Length)
        self.assertEqual(orig.Width, stock.Width)
        self.assertEqual(orig.Height, stock.Height)
        self.assertPlacement(FreeCAD.Placement(), stock.Placement)
예제 #18
0
 def setFields(self, obj):
     if not self.IsStock(obj):
         self.setStock(obj, PathStock.CreateCylinder(obj))
     self.setLengthField(self.form.stockCylinderRadius, obj.Stock.Radius)
     self.setLengthField(self.form.stockCylinderHeight, obj.Stock.Height)
예제 #19
0
 def setFields(self, obj):
     if not self.IsStock(obj):
         self.setStock(obj, PathStock.CreateBox(obj))
     self.setLengthField(self.form.stockBoxLength, obj.Stock.Length)
     self.setLengthField(self.form.stockBoxWidth, obj.Stock.Width)
     self.setLengthField(self.form.stockBoxHeight, obj.Stock.Height)
예제 #20
0
파일: PathJob.py 프로젝트: Roy-043/FreeCAD
 def modelBoundBox(self, obj):
     return PathStock.shapeBoundBox(obj.Model.Group)
예제 #21
0
 def modelBoundBox(self, obj):
     return PathStock.shapeBoundBox(obj.Model.Group)