Exemplo n.º 1
0
    def test00(self):
        '''Verify ToolController templateAttrs'''
        t = self.createTool('T1')
        tc = PathToolController.Create('TC0', t)

        tc.Label = 'ToolController'
        tc.ToolNumber = 7
        tc.VertFeed = '3 in/s'
        tc.VertFeed = round(tc.VertFeed, 1)
        tc.HorizFeed = '10 mm/s'
        tc.VertRapid = 40
        tc.HorizRapid = 28
        tc.SpindleDir = 'Reverse'
        tc.SpindleSpeed = 12000

        attrs = tc.Proxy.templateAttrs(tc)

        self.assertEqual(attrs['name'], 'TC0')
        self.assertEqual(attrs['label'], 'ToolController')
        self.assertEqual(attrs['nr'], 7)
        self.assertEqual(attrs['vfeed'], '76.2 mm/s')
        self.assertEqual(attrs['hfeed'], '10.0 mm/s')
        self.assertEqual(attrs['vrapid'], '40.0 mm/s')
        self.assertEqual(attrs['hrapid'], '28.0 mm/s')
        self.assertEqual(attrs['dir'], 'Reverse')
        self.assertEqual(attrs['speed'], 12000)
        if PathPreferences.toolsReallyUseLegacyTools():
            self.assertEqual(attrs['tool'], t.templateAttrs())
        else:
            self.assertEqual(attrs['tool'], t.Proxy.templateAttrs(t))

        return tc
Exemplo n.º 2
0
def Create(name='TC: Default Tool', tool=None, toolNumber=1, assignViewProvider=True):
    legacyTool = PathPreferences.toolsReallyUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)

    PathLog.track(tool, toolNumber, legacyTool)

    obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
    obj.Label = name
    obj.Proxy = ToolController(obj, legacyTool)

    if FreeCAD.GuiUp and assignViewProvider:
        ViewProvider(obj.ViewObject)

    if tool is None:
        if legacyTool:
            tool = Path.Tool()
            tool.Diameter = 5.0
            tool.Name = "Default Tool"
            tool.CuttingEdgeHeight = 15.0
            tool.ToolType = "EndMill"
            tool.Material = "HighSpeedSteel"
        else:
            tool = PathToolBit.Factory.Create()
            if tool.ViewObject:
                tool.ViewObject.Visibility = False

    obj.Tool = tool
    obj.ToolNumber = toolNumber
    return obj
Exemplo n.º 3
0
 def edit(self, job=None, cb=None):
     if PathPreferences.toolsReallyUseLegacyTools():
         editor = EditorPanel(job, cb)
         editor.setupUi()
         editor.form.exec_()
     else:
         if PathToolBitLibraryCmd.CommandToolBitLibraryLoad.Execute(job):
             if cb:
                 cb()
Exemplo n.º 4
0
 def createTool(self, name='t1', diameter=1.75):
     if PathPreferences.toolsReallyUseLegacyTools():
         return Path.Tool(name=name, diameter=diameter)
     attrs = {
         'shape': None,
         'name': name,
         'parameter': {
             'Diameter': diameter
         },
         'attribute': []
     }
     return PathToolBit.Factory.CreateFromAttrs(attrs, name)
Exemplo n.º 5
0
    def Initialize(self):
        global PathCommandGroup

        # Add preferences pages - before loading PathGui to properly order pages of Path group
        from PathScripts import PathPreferencesPathJob, PathPreferencesPathDressup
        FreeCADGui.addPreferencePage(PathPreferencesPathJob.JobPreferencesPage,
                                     "Path")
        FreeCADGui.addPreferencePage(
            PathPreferencesPathDressup.DressupPreferencesPage, "Path")

        # Check enablement of experimental features
        from PathScripts import PathPreferences

        # load the builtin modules
        import Path
        import PathScripts
        import PathGui
        from PySide import QtCore, QtGui
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addIconPath(":/icons")
        from PathScripts import PathGuiInit
        from PathScripts import PathJobCmd

        from PathScripts import PathToolBitCmd
        from PathScripts import PathToolBitLibraryCmd

        import PathCommands
        PathGuiInit.Startup()

        # build commands list
        projcmdlist = ["Path_Job", "Path_Post"]
        toolcmdlist = [
            "Path_Inspect", "Path_Simulator", "Path_SelectLoop",
            "Path_OpActiveToggle"
        ]
        prepcmdlist = [
            "Path_Fixture", "Path_Comment", "Path_Stop", "Path_Custom",
            "Path_Probe"
        ]
        twodopcmdlist = [
            "Path_Profile", "Path_Pocket_Shape", "Path_Drilling",
            "Path_MillFace", "Path_Helix", "Path_Adaptive", "Path_Slot"
        ]
        threedopcmdlist = ["Path_Pocket_3D"]
        engravecmdlist = ["Path_Engrave", "Path_Deburr", "Path_Vcarve"]
        modcmdlist = ["Path_OperationCopy", "Path_Array", "Path_SimpleCopy"]
        dressupcmdlist = [
            "Path_DressupAxisMap", "Path_DressupPathBoundary",
            "Path_DressupDogbone", "Path_DressupDragKnife",
            "Path_DressupLeadInOut", "Path_DressupRampEntry",
            "Path_DressupTag", "Path_DressupZCorrect"
        ]
        extracmdlist = []
        # modcmdmore = ["Path_Hop",]
        # remotecmdlist = ["Path_Remote"]
        specialcmdlist = []

        if PathPreferences.toolsReallyUseLegacyTools():
            toolcmdlist.append("Path_ToolLibraryEdit")
            toolbitcmdlist = []
        else:
            toolcmdlist.extend(PathToolBitLibraryCmd.BarList)
            toolbitcmdlist = PathToolBitLibraryCmd.MenuList

        engravecmdgroup = ['Path_EngraveTools']
        FreeCADGui.addCommand(
            'Path_EngraveTools',
            PathCommandGroup(
                engravecmdlist,
                QtCore.QT_TRANSLATE_NOOP("Path", 'Engraving Operations')))

        threedcmdgroup = threedopcmdlist
        if PathPreferences.experimentalFeaturesEnabled():
            projcmdlist.append("Path_Sanity")
            prepcmdlist.append("Path_Shape")
            extracmdlist.extend(["Path_Area", "Path_Area_Workplane"])
            specialcmdlist.append('Path_Thread_Milling')

            try:
                import ocl  # pylint: disable=unused-variable
                from PathScripts import PathSurfaceGui
                from PathScripts import PathWaterlineGui
                threedopcmdlist.extend(["Path_Surface", "Path_Waterline"])
                threedcmdgroup = ['Path_3dTools']
                FreeCADGui.addCommand(
                    'Path_3dTools',
                    PathCommandGroup(
                        threedopcmdlist,
                        QtCore.QT_TRANSLATE_NOOP("Path", '3D Operations')))
            except ImportError:
                if not PathPreferences.suppressOpenCamLibWarning():
                    FreeCAD.Console.PrintError("OpenCamLib is not working!\n")

        self.appendToolbar(QtCore.QT_TRANSLATE_NOOP("Path", "Project Setup"),
                           projcmdlist)
        self.appendToolbar(QtCore.QT_TRANSLATE_NOOP("Path", "Tool Commands"),
                           toolcmdlist)
        self.appendToolbar(QtCore.QT_TRANSLATE_NOOP("Path", "New Operations"),
                           twodopcmdlist + engravecmdgroup + threedcmdgroup)
        self.appendToolbar(
            QtCore.QT_TRANSLATE_NOOP("Path", "Path Modification"), modcmdlist)
        if extracmdlist:
            self.appendToolbar(
                QtCore.QT_TRANSLATE_NOOP("Path", "Helpful Tools"),
                extracmdlist)

        self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")],
                        projcmdlist + ["Path_ExportTemplate", "Separator"] +
                        toolcmdlist + toolbitcmdlist + ["Separator"] +
                        twodopcmdlist + engravecmdlist + ["Separator"] +
                        threedopcmdlist + ["Separator"])
        self.appendMenu([
            QtCore.QT_TRANSLATE_NOOP("Path", "&Path"),
            QtCore.QT_TRANSLATE_NOOP("Path", "Path Dressup")
        ], dressupcmdlist)
        self.appendMenu([
            QtCore.QT_TRANSLATE_NOOP("Path", "&Path"),
            QtCore.QT_TRANSLATE_NOOP("Path", "Supplemental Commands")
        ], prepcmdlist)
        self.appendMenu([
            QtCore.QT_TRANSLATE_NOOP("Path", "&Path"),
            QtCore.QT_TRANSLATE_NOOP("Path", "Path Modification")
        ], modcmdlist)
        if specialcmdlist:
            self.appendMenu([
                QtCore.QT_TRANSLATE_NOOP("Path", "&Path"),
                QtCore.QT_TRANSLATE_NOOP("Path", "Specialty Operations")
            ], specialcmdlist)
        if extracmdlist:
            self.appendMenu([QtCore.QT_TRANSLATE_NOOP("Path", "&Path")],
                            extracmdlist)

        self.dressupcmds = dressupcmdlist

        curveAccuracy = PathPreferences.defaultLibAreaCurveAccuracy()
        if curveAccuracy:
            Path.Area.setDefaultParams(Accuracy=curveAccuracy)

        Log('Loading Path workbench... done\n')