Exemplo n.º 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)