Example #1
0
 def Activated(self, shapeType=None):
     self.ShapeType = shapeType
     name = DraftTools.translate("draft", "Rectangle")
     DraftTools.Creator.Activated(self, name)
     if self.ui:
         self.refpoint = None
         self.ui.pointUi(name)
         self.ui.extUi()
         self.call = self.view.addEventCallback("SoEvent", self.action)
         self.rect = trackers.rectangleTracker()
         Utils.EB_Print.print_msg(
             DraftTools.translate("draft", "Pick first point:") + "\n")
Example #2
0
    def Activated(self):
        wires = FreeCADGui.Selection.getSelection()
        if not wires:
            FCC.PrintError("CommandFillet: two elements needed" + "\n")
            return

        if len(wires) != 2:
            FCC.PrintError("CommandFillet: two elements needed" + "\n")
            return

        for o in wires:
            FCC.PrintMessage("CommandFillet: " + Draft.getType(o) + "\n")

            # Choose only wires.
            # A test could be used to chose edges in general.
            if Draft.getType(o) not in "Wire":
                FCC.PrintError("CommandFillet: wires needed" + "\n")
                return

        doc = 'FreeCAD.ActiveDocument.'
        _wires = '[' + doc + wires[0].Name + ', ' + doc + wires[1].Name + ']'
        rems = [doc + 'removeObject("' + o.Name + '")' for o in wires]
        FreeCADGui.addModule("Draft")
        func = DraftTools.translate("draft", "Create fillet")

        arg = [
            'arc = DraftFillet.makeFillet(' + _wires + ')', *rems,
            'Draft.autogroup(arc)', 'FreeCAD.ActiveDocument.recompute()'
        ]
        DraftGui.todo.delayCommit([(func, arg)])
Example #3
0
 def Initialize(self):
     # run self-tests
     depsOK = False
     try:
         from pivy import coin
         if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
             raise AssertionError("FreeCAD and Pivy use different versions of Coin. This will lead to unexpected behaviour.")
     except AssertionError:
         FreeCAD.Console.PrintWarning("Error: FreeCAD and Pivy use different versions of Coin. This will lead to unexpected behaviour.\n")
     except ImportError:
         FreeCAD.Console.PrintWarning("Error: Pivy not found, Draft workbench will be disabled.\n")
     except:
         FreeCAD.Console.PrintWarning("Error: Unknown error while trying to load Pivy\n")
     else:
         try:
             import PyQt4
         except ImportError:
             FreeCAD.Console.PrintWarning("Error: PyQt4 not found, Draft workbench will be disabled.\n")
         else:
             depsOK = True
     if not depsOK:
         return
 
     try:
         import os,macros,DraftTools,DraftGui,Draft_rc
         FreeCADGui.addLanguagePath(":/translations")
         FreeCADGui.addIconPath(":/icons")
         if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
             FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
             FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
             FreeCADGui.draftToolBar.loadedPreferences = True
         self.appendMenu(["&Macro",str(DraftTools.translate("draft","Installed Macros"))],macros.macrosList)
         Log ('Loading Draft module...done\n')
     except:
         pass
     self.cmdList = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
                     "Draft_Polygon","Draft_Rectangle", "Draft_Text",
                     "Draft_Dimension", "Draft_BSpline","Draft_Point",
                     "Draft_ShapeString"]
     self.modList = ["Draft_Move","Draft_Rotate","Draft_Offset",
                     "Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
                     "Draft_Drawing","Draft_Edit","Draft_WireToBSpline","Draft_AddPoint",
                     "Draft_DelPoint","Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array",
                     "Draft_Clone","Draft_Heal"]
     self.treecmdList = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
                         "Draft_SelectGroup","Draft_SelectPlane","Draft_ToggleSnap",
                         "Draft_ShowSnapBar","Draft_ToggleGrid"]
     self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"]
     self.appendToolbar(str(DraftTools.translate("draft","Draft creation tools")),self.cmdList)
     self.appendToolbar(str(DraftTools.translate("draft","Draft modification tools")),self.modList)
     self.appendMenu(str(DraftTools.translate("draft","&Draft")),self.cmdList+self.modList)
     self.appendMenu([str(DraftTools.translate("draft","&Draft")),str(DraftTools.translate("draft","Context tools"))],self.treecmdList)
     self.appendMenu([str(DraftTools.translate("draft","&Draft")),str(DraftTools.translate("draft","Wire tools"))],self.lineList)
Example #4
0
 def Initialize(self):
     import DraftTools,DraftGui,Arch_rc,Arch
     self.archtools = ["Arch_Wall","Arch_Structure",
                  "Arch_Floor","Arch_Building","Arch_Site",
                  "Arch_Window","Arch_Roof","Arch_Axis",
                  "Arch_SectionPlane","Arch_Add","Arch_Remove"]
     self.drafttools = ["Draft_Line","Draft_Wire","Draft_Rectangle",
                   "Draft_Polygon","Draft_Arc",
                   "Draft_Circle","Draft_Dimension",
                   "Draft_Move","Draft_Rotate",
                   "Draft_Offset","Draft_Upgrade",
                   "Draft_Downgrade","Draft_Trimex"]
     self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode",
                               "Draft_AddToGroup","Draft_SelectGroup",
                               "Draft_SelectPlane","Draft_ToggleSnap",
                               "Draft_ShowSnapBar","Draft_ToggleGrid"]
     self.meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
                  "Arch_SelectNonSolidMeshes","Arch_RemoveShape"]
     self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
     self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
     self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Conversion Tools"))],self.meshtools)
     self.appendMenu(str(DraftTools.translate("arch","&Architecture")),self.archtools)
     self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftcontexttools)
     FreeCADGui.addIconPath(":/icons")
     FreeCADGui.addLanguagePath(":/translations")
     FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
     Log ('Loading Arch module... done\n')
Example #5
0
 def appendPoint(self, point):
     self.node.append(point)
     if (len(self.node) > 1):
         self.rect.update(point)
         self.createObject()
     else:
         Utils.EB_Print.print_msg(
             DraftTools.translate("draft", "Pick opposite point:") + "\n")
         self.ui.setRelative()
         self.rect.setorigin(point)
         self.rect.on()
         if self.planetrack:
             self.planetrack.set(point)
Example #6
0
 def Initialize(self):
     import DraftTools, DraftGui, Arch_rc, Arch
     self.archtools = [
         "Arch_Wall", "Arch_Structure", "Arch_Floor", "Arch_Building",
         "Arch_Site", "Arch_Window", "Arch_Roof", "Arch_Axis",
         "Arch_SectionPlane", "Arch_Add", "Arch_Remove"
     ]
     self.drafttools = [
         "Draft_Line", "Draft_Wire", "Draft_Rectangle", "Draft_Polygon",
         "Draft_Arc", "Draft_Circle", "Draft_Dimension", "Draft_Move",
         "Draft_Rotate", "Draft_Offset", "Draft_Upgrade", "Draft_Downgrade",
         "Draft_Trimex"
     ]
     self.draftcontexttools = [
         "Draft_ApplyStyle", "Draft_ToggleDisplayMode", "Draft_AddToGroup",
         "Draft_SelectGroup", "Draft_SelectPlane", "Draft_ToggleSnap",
         "Draft_ShowSnapBar", "Draft_ToggleGrid"
     ]
     self.meshtools = [
         "Arch_SplitMesh", "Arch_MeshToShape", "Arch_SelectNonSolidMeshes",
         "Arch_RemoveShape"
     ]
     self.appendToolbar(str(DraftTools.translate("arch", "Arch tools")),
                        self.archtools)
     self.appendToolbar(str(DraftTools.translate("arch", "Draft tools")),
                        self.drafttools)
     self.appendMenu([
         str(DraftTools.translate("arch", "&Architecture")),
         str(DraftTools.translate("arch", "Conversion Tools"))
     ], self.meshtools)
     self.appendMenu(str(DraftTools.translate("arch", "&Architecture")),
                     self.archtools)
     self.appendMenu(str(DraftTools.translate("arch", "&Draft")),
                     self.drafttools + self.draftcontexttools)
     FreeCADGui.addIconPath(":/icons")
     FreeCADGui.addLanguagePath(":/translations")
     FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui", "Arch")
     Log('Loading Arch module... done\n')
Example #7
0
    def Initialize(self):
        # run self-tests
        depsOK = False
        try:
            from pivy import coin
            if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError(
                    "FreeCAD and Pivy use different versions of Coin. This will lead to unexpected behaviour."
                )
        except AssertionError:
            FreeCAD.Console.PrintWarning(
                "Error: FreeCAD and Pivy use different versions of Coin. This will lead to unexpected behaviour.\n"
            )
        except ImportError:
            FreeCAD.Console.PrintWarning(
                "Error: Pivy not found, Draft workbench will be disabled.\n")
        except:
            FreeCAD.Console.PrintWarning(
                "Error: Unknown error while trying to load Pivy\n")
        else:
            try:
                import PyQt4
            except ImportError:
                FreeCAD.Console.PrintWarning(
                    "Error: PyQt4 not found, Draft workbench will be disabled.\n"
                )
            else:
                depsOK = True

        if depsOK:
            import Draft_rc
            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
            FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui", "Draft")
            FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui", "Draft")
        else:
            return
        try:
            import macros, DraftTools, DraftGui
            self.appendMenu([
                "&Macro",
                str(DraftTools.translate("draft", "Installed Macros"))
            ], macros.macrosList)
            Log('Loading Draft GUI...done\n')
        except:
            pass
        self.cmdList = [
            "Draft_Line", "Draft_Wire", "Draft_Circle", "Draft_Arc",
            "Draft_Polygon", "Draft_Rectangle", "Draft_Text",
            "Draft_Dimension", "Draft_BSpline", "Draft_Point"
        ]
        self.modList = [
            "Draft_Move", "Draft_Rotate", "Draft_Offset", "Draft_Trimex",
            "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale", "Draft_Drawing",
            "Draft_Edit", "Draft_WireToBSpline", "Draft_AddPoint",
            "Draft_DelPoint", "Draft_Shape2DView", "Draft_Draft2Sketch",
            "Draft_Array"
        ]
        self.treecmdList = [
            "Draft_ApplyStyle", "Draft_ToggleDisplayMode", "Draft_AddToGroup",
            "Draft_SelectGroup", "Draft_SelectPlane", "Draft_ToggleSnap",
            "Draft_ShowSnapBar"
        ]
        self.lineList = [
            "Draft_UndoLine", "Draft_FinishLine", "Draft_CloseLine"
        ]
        self.appendToolbar(
            str(DraftTools.translate("draft", "Draft creation tools")),
            self.cmdList)
        self.appendToolbar(
            str(DraftTools.translate("draft", "Draft modification tools")),
            self.modList)
        self.appendMenu(str(DraftTools.translate("draft", "&Draft")),
                        self.cmdList + self.modList)
        self.appendMenu([
            str(DraftTools.translate("draft", "&Draft")),
            str(DraftTools.translate("draft", "Display options"))
        ], self.treecmdList)
        self.appendMenu([
            str(DraftTools.translate("draft", "&Draft")),
            str(DraftTools.translate("draft", "Wire tools"))
        ], self.lineList)
Example #8
0
    def Initialize(self):
        import DraftTools,DraftGui,Arch_rc,Arch,Draft_rc

        # arch tools
        self.archtools = ["Arch_Wall","Arch_Structure",
                     "Arch_Floor","Arch_Building","Arch_Site",
                     "Arch_Window","Arch_Roof","Arch_Axis",
                     "Arch_SectionPlane","Arch_Add","Arch_Remove"]
        self.meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
                     "Arch_SelectNonSolidMeshes","Arch_RemoveShape",
                     "Arch_CloseHoles"]
        self.calctools = ["Arch_Check"]

        # draft tools
        self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc",
                        "Draft_Polygon","Draft_Rectangle", "Draft_Text",
                        "Draft_Dimension", "Draft_BSpline","Draft_Point"]
        self.draftmodtools = ["Draft_Move","Draft_Rotate","Draft_Offset",
                        "Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
                        "Draft_Drawing","Draft_Edit","Draft_WireToBSpline","Draft_AddPoint",
                        "Draft_DelPoint","Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array",
                        "Draft_Clone","Draft_Heal"]
        self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
                            "Draft_SelectGroup","Draft_SelectPlane","Draft_ToggleSnap",
                            "Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
                            "Draft_FinishLine","Draft_CloseLine"]

        self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
        self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
        self.appendToolbar(str(DraftTools.translate("arch","Draft mod tools")),self.draftmodtools)
        self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Conversion Tools"))],self.meshtools)
        self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Calculation Tools"))],self.calctools)
        self.appendMenu(str(DraftTools.translate("arch","&Architecture")),self.archtools)
        self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftmodtools)
        self.appendMenu([str(DraftTools.translate("arch","&Draft")),str(DraftTools.translate("arch","Context Tools"))],self.draftcontexttools)
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
        if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
            FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
            FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
            FreeCADGui.draftToolBar.loadedPreferences = True
        Log ('Loading Arch module... done\n')
    def Initialize(self):
        import DraftTools,DraftGui,Arch_rc,Arch,Draft_rc

        # arch tools
        self.archtools = ["Arch_Wall","Arch_Structure",
                     "Arch_Floor","Arch_Building","Arch_Site",
                     "Arch_Window","Arch_Roof","Arch_Axis",
                     "Arch_SectionPlane","Arch_Add","Arch_Remove"]
        self.meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
                     "Arch_SelectNonSolidMeshes","Arch_RemoveShape",
                     "Arch_CloseHoles","Arch_MergeWalls"]
        self.calctools = ["Arch_Check"]

        # draft tools
        self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
                        "Draft_Polygon","Draft_Rectangle", "Draft_Text",
                        "Draft_Dimension", "Draft_BSpline","Draft_Point"]
        self.draftmodtools = ["Draft_Move","Draft_Rotate","Draft_Offset",
                        "Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
                        "Draft_Drawing","Draft_Edit","Draft_WireToBSpline","Draft_AddPoint",
                        "Draft_DelPoint","Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array",
                        "Draft_Clone","Draft_Heal"]
        self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup",
                            "Draft_SelectGroup","Draft_SelectPlane","Draft_ToggleSnap",
                            "Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
                            "Draft_FinishLine","Draft_CloseLine"]

        self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
        self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
        self.appendToolbar(str(DraftTools.translate("arch","Draft mod tools")),self.draftmodtools)
        self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Conversion Tools"))],self.meshtools)
        self.appendMenu([str(DraftTools.translate("arch","&Architecture")),str(DraftTools.translate("arch","Calculation Tools"))],self.calctools)
        self.appendMenu(str(DraftTools.translate("arch","&Architecture")),self.archtools)
        self.appendMenu(str(DraftTools.translate("arch","&Draft")),self.drafttools+self.draftmodtools)
        self.appendMenu([str(DraftTools.translate("arch","&Draft")),str(DraftTools.translate("arch","Context Tools"))],self.draftcontexttools)
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
        if not hasattr(FreeCADGui.draftToolBar,"loadedPreferences"):
            FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
            FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
            FreeCADGui.draftToolBar.loadedPreferences = True
        Log ('Loading Arch module... done\n')