当前位置: 首页>>代码示例>>Python>>正文


Python PathUtil.toolControllerForOp方法代码示例

本文整理汇总了Python中PathScripts.PathUtil.toolControllerForOp方法的典型用法代码示例。如果您正苦于以下问题:Python PathUtil.toolControllerForOp方法的具体用法?Python PathUtil.toolControllerForOp怎么用?Python PathUtil.toolControllerForOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PathScripts.PathUtil的用法示例。


在下文中一共展示了PathUtil.toolControllerForOp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setDefaultValues

# 需要导入模块: from PathScripts import PathUtil [as 别名]
# 或者: from PathScripts.PathUtil import toolControllerForOp [as 别名]
    def setDefaultValues(self, obj):
        '''setDefaultValues(obj) ... base implementation.
        Do not overwrite, overwrite opSetDefaultValues() instead.'''
        job = PathUtils.addToJob(obj)

        obj.Active = True

        features = self.opFeatures(obj)

        if FeatureTool & features:
            if 1 < len(job.Operations.Group):
                obj.ToolController = PathUtil.toolControllerForOp(job.Operations.Group[-2])
            else:
                obj.ToolController = PathUtils.findToolController(obj)
            if not obj.ToolController:
                return None
            obj.OpToolDiameter = obj.ToolController.Tool.Diameter

        if FeatureDepths & features:
            if self.applyExpression(obj, 'StartDepth', job.SetupSheet.StartDepthExpression):
                obj.OpStartDepth = 1.0
            else:
                obj.StartDepth = 1.0
            if self.applyExpression(obj, 'FinalDepth', job.SetupSheet.FinalDepthExpression):
                obj.OpFinalDepth = 0.0
            else:
                obj.FinalDepth = 0.0
        else:
            obj.StartDepth = 1.0

        if FeatureStepDown & features:
            if not self.applyExpression(obj, 'StepDown', job.SetupSheet.StepDownExpression):
                obj.StepDown = '1 mm'

        if FeatureHeights & features:
            if job.SetupSheet.SafeHeightExpression:
                if not self.applyExpression(obj, 'SafeHeight', job.SetupSheet.SafeHeightExpression):
                    obj.SafeHeight = '3 mm'
            if job.SetupSheet.ClearanceHeightExpression:
                if not self.applyExpression(obj, 'ClearanceHeight', job.SetupSheet.ClearanceHeightExpression):
                    obj.ClearanceHeight = '5 mm'

        if FeatureStartPoint & features:
            obj.UseStartPoint = False

        self.opSetDefaultValues(obj, job)
        return job
开发者ID:frankhardy,项目名称:FreeCAD,代码行数:49,代码来源:PathOp.py

示例2: Activated

# 需要导入模块: from PathScripts import PathUtil [as 别名]
# 或者: from PathScripts.PathUtil import toolControllerForOp [as 别名]
    def Activated(self):
        PathLog.track()
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Post", "Post Process the Selected path(s)"))
        FreeCADGui.addModule("PathScripts.PathPost")

        # Attempt to figure out what the user wants to post-process
        # If a job is selected, post that.
        # If there's only one job in a document, post it.
        # If a user has selected a subobject of a job, post the job.
        # If multiple jobs and can't guess, ask them.

        selected = FreeCADGui.Selection.getSelectionEx()
        if len(selected) > 1:
            FreeCAD.Console.PrintError("Please select a single job or other path object\n")
            return
        elif len(selected) == 1:
            sel = selected[0].Object
            if sel.Name[:3] == "Job":
                job = sel
            elif hasattr(sel, "Path"):
                try:
                    job = PathUtils.findParentJob(sel)
                except:
                    job = None
            else:
                job = None
        if job is None:
            targetlist = []
            for o in FreeCAD.ActiveDocument.Objects:
                if hasattr(o, "Proxy"):
                    if isinstance(o.Proxy, PathJob.ObjectJob):
                        targetlist.append(o.Label)
            PathLog.debug("Possible post objects: {}".format(targetlist))
            if len(targetlist) > 1:
                form = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobChooser.ui")
                form.cboProject.addItems(targetlist)
                r = form.exec_()
                if r is False:
                    return
                else:
                    jobname = form.cboProject.currentText()
            else:
                jobname = targetlist[0]
            job = FreeCAD.ActiveDocument.getObject(jobname)

        PathLog.debug("about to postprocess job: {}".format(job.Name))

        # Build up an ordered list of operations and tool changes.
        # Then post-the ordered list
        postlist = []
        currTool = None
        for obj in job.Operations.Group:
            PathLog.debug("obj: {}".format(obj.Name))
            tc = PathUtil.toolControllerForOp(obj)
            if tc is not None:
                if tc.ToolNumber != currTool:
                    postlist.append(tc)
            postlist.append(obj)

        fail = True
        rc = ''
        (fail, rc) = self.exportObjectsWith(postlist, job)

        if fail:
            FreeCAD.ActiveDocument.abortTransaction()
        else:
            FreeCAD.ActiveDocument.commitTransaction()
        FreeCAD.ActiveDocument.recompute()
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:71,代码来源:PathPost.py


注:本文中的PathScripts.PathUtil.toolControllerForOp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。