Пример #1
0
    def Activated(self):
        # retrieve Selection
        selection = FreeCAD.Gui.Selection.getSelectionEx()
        for i in range(len(selection)):
            # create WirePath folder if it does not exist
            try:
                WPFolder = FreeCAD.ActiveDocument.WirePath

            except:
                WPFolder = FreeCAD.ActiveDocument.addObject(
                    'App::DocumentObjectGroupPython', 'WirePath')
                NiCrPath.WirePathFolder(WPFolder)
                NiCrPath.WirePathViewProvider(WPFolder)

            # create shapepath object
            selObj = selection[i].Object
            shapepath_name = 'ShapePath_' + selObj.Name
            shapepathobj = FreeCAD.ActiveDocument.addObject(
                'Part::FeaturePython', shapepath_name)
            # initialize python object
            NiCrPath.ShapePath(shapepathobj, selObj)
            NiCrPath.ShapePathViewProvider(shapepathobj.ViewObject)
            # modify color
            shapepathobj.ViewObject.ShapeColor = (1.0, 1.0, 1.0)
            shapepathobj.ViewObject.LineWidth = 1.0
            WPFolder.addObject(shapepathobj)
Пример #2
0
    def Activated(self):
        # retrieve selection
        selection = FreeCAD.Gui.Selection.getSelectionEx()
        if len(selection) == 1:
            # Create initial/end path if length of selection == 1
            selObj = selection[0]
            try:
                a = FreeCAD.ActiveDocument.InitialPath
                try:
                    a = FreeCAD.ActiveDocument.FinalPath

                except:
                    # create final path, because initial path already exists
                    finalobj = FreeCAD.ActiveDocument.addObject(
                        'Part::FeaturePython', 'FinalPath')
                    NiCrPath.FinalPath(finalobj, selObj)
                    NiCrPath.FinalPathViewProvider(finalobj.ViewObject)
                    finalobj.ViewObject.ShapeColor = (1.0, 1.0, 1.0)
                    finalobj.ViewObject.Transparency = 15
                    finalobj.ViewObject.DisplayMode = 'Shaded'
                    FreeCAD.ActiveDocument.WirePath.addObject(finalobj)

            except:
                # create initial path object
                initialobj = FreeCAD.ActiveDocument.addObject(
                    'Part::FeaturePython', 'InitialPath')
                NiCrPath.InitialPath(initialobj, selObj)
                NiCrPath.InitialPathViewProvider(initialobj.ViewObject)
                # initial trajectory is red
                initialobj.ViewObject.ShapeColor = (1.0, 0.0, 0.0)
                initialobj.ViewObject.Transparency = 15
                initialobj.ViewObject.DisplayMode = 'Shaded'
                FreeCAD.ActiveDocument.WirePath.addObject(initialobj)

        if len(selection) == 2:
            # Create link between paths if len(selection) = 2
            selA = selection[0]
            selB = selection[1]
            SelObjA = selA.Object
            SelObjB = selA.Object
            # Link object
            link_name = 'Link_' + SelObjA.Name[8:] + '_' + SelObjB.Name[8:]
            LinkObj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython',
                                                       link_name)
            # initialize link object
            NiCrPath.LinkPath(LinkObj, selA, selB)
            NiCrPath.LinkPathViewProvider(LinkObj.ViewObject)
            # link representation
            # LinkObj.ViewObject.ShapeColor = (1.0, 0.0, 0.0)
            LinkObj.ViewObject.Transparency = 15
            # LinkObj.ViewObject.LineColor = (1.0, 0.0, 0.0)
            LinkObj.ViewObject.DisplayMode = "Shaded"
            # add to folder
            FreeCAD.ActiveDocument.WirePath.addObject(LinkObj)
Пример #3
0
 def Activated(self):
     NiCrPath.importNiCrFile()
Пример #4
0
 def Activated(self):
     NiCrPath.saveNiCrFile()
Пример #5
0
 def Activated(self):
     full_path = NiCrPath.CreateCompleteRawPath()
     NiCrSM.runSimulation(full_path)
     FreeCAD.Console.PrintMessage('Simulation finished\n')
Пример #6
0
 def Activated(self):
     NiCrPath.importNiCrFile()
Пример #7
0
 def Activated(self):
     NiCrPath.saveNiCrFile()