Ejemplo n.º 1
0
    def Initialize(self):
        """When the workbench is first loaded."""
        def QT_TRANSLATE_NOOP(context, text):
            return text

        import Draft_rc
        import DraftTools
        import DraftGui
        import Arch_rc
        import Arch

        from ArchStructure import _ArchStructureGroupCommand
        from ArchAxis import _ArchAxisGroupCommand
        from ArchPanel import CommandPanelGroup
        from ArchMaterial import _ArchMaterialToolsCommand
        from ArchPipe import _ArchPipeGroupCommand

        stru_group = _ArchStructureGroupCommand
        axis_group = _ArchAxisGroupCommand
        pan_group = CommandPanelGroup
        mat_group = _ArchMaterialToolsCommand
        pipe_group = _ArchPipeGroupCommand

        # Set up command lists
        self.archtools = [
            "Arch_Wall",
            ([QT_TRANSLATE_NOOP("Workbench", "Structure tools")],
             list(stru_group.GetCommands(stru_group))),  # tuple len=2: submenu
            ("Arch_StructureTools", ),  # tuple len=1: toolbar flyout
            "Arch_Rebar_Submenu",  # will be replaced or removed
            "Arch_Rebar",  # may be replaced
            "Arch_CurtainWall",
            "Arch_BuildingPart",
            "Arch_Project",
            "Arch_Site",
            "Arch_Building",
            "Arch_Floor",
            "Arch_Reference",
            "Arch_Window",
            "Arch_Roof",
            ([QT_TRANSLATE_NOOP("Workbench", "Axis tools")],
             list(axis_group.GetCommands(axis_group))),
            ("Arch_AxisTools", ),
            "Arch_SectionPlane",
            "Arch_Space",
            "Arch_Stairs",
            ([QT_TRANSLATE_NOOP("Workbench", "Panel tools")],
             list(pan_group.GetCommands(pan_group))),
            ("Arch_PanelTools", ),
            "Arch_Equipment",
            "Arch_Frame",
            "Arch_Fence",
            "Arch_Truss",
            "Arch_Profile",
            ([QT_TRANSLATE_NOOP("Workbench", "Material tools")],
             list(mat_group.GetCommands(mat_group))),
            ("Arch_MaterialTools", ),
            "Arch_Schedule",
            ([QT_TRANSLATE_NOOP("Workbench", "Pipe tools")],
             list(pipe_group.GetCommands(pipe_group))),
            ("Arch_PipeTools", ),
            "Arch_CutPlane",
            "Arch_CutLine",
            "Arch_Add",
            "Arch_Remove",
            "Arch_Survey"
        ]

        self.utilities = [
            "Arch_Component", "Arch_CloneComponent", "Arch_SplitMesh",
            "Arch_MeshToShape", "Arch_SelectNonSolidMeshes",
            "Arch_RemoveShape", "Arch_CloseHoles", "Arch_MergeWalls",
            "Arch_Check", "Arch_ToggleIfcBrepFlag", "Arch_3Views",
            "Arch_IfcSpreadsheet", "Arch_ToggleSubs"
        ]

        # Add the rebar tools from the Reinforcement addon, if available
        try:
            import RebarTools
        except Exception:
            del self.archtools[3]  # remove "Arch_Rebar_Submenu"
        else:

            class RebarGroupCommand:
                def GetCommands(self):
                    return tuple(RebarTools.RebarCommands + ["Arch_Rebar"])

                def GetResources(self):
                    return {
                        'MenuText':
                        QT_TRANSLATE_NOOP("Arch_RebarTools", "Rebar tools"),
                        'ToolTip':
                        QT_TRANSLATE_NOOP(
                            "Arch_RebarTools",
                            "Create various types of rebars, "
                            "including U-shaped, L-shaped, and stirrup")
                    }

                def IsActive(self):
                    return not FreeCAD.ActiveDocument is None

            FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
            self.archtools[3] = ([
                QT_TRANSLATE_NOOP("Workbench", "Rebar tools")
            ], RebarTools.RebarCommands + ["Arch_Rebar"])
            self.archtools[4] = ("Arch_RebarTools", )

        # Set up Draft command lists
        import draftutils.init_tools as it
        self.draft_drawing_commands = it.get_draft_drawing_commands()
        self.draft_annotation_commands = it.get_draft_annotation_commands()
        self.draft_modification_commands = it.get_draft_modification_commands()
        self.draft_utility_commands = it.get_draft_utility_commands_menu()
        self.draft_context_commands = it.get_draft_context_commands()

        # Set up toolbars
        it.init_toolbar(self, QT_TRANSLATE_NOOP("Workbench", "Arch tools"),
                        self.archtools)
        it.init_toolbar(self,
                        QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"),
                        self.draft_drawing_commands)
        it.init_toolbar(
            self, QT_TRANSLATE_NOOP("Workbench", "Draft annotation tools"),
            self.draft_annotation_commands)
        it.init_toolbar(
            self, QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"),
            self.draft_modification_commands)

        # Set up menus
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Arch"),
            QT_TRANSLATE_NOOP("Workbench", "Utilities")
        ], self.utilities)
        it.init_menu(self, [QT_TRANSLATE_NOOP("Workbench", "&Arch")],
                     self.archtools)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Creation")
        ], self.draft_drawing_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Annotation")
        ], self.draft_annotation_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Modification")
        ], self.draft_modification_commands)
        it.init_menu(self, [
            QT_TRANSLATE_NOOP("Workbench", "&Draft"),
            QT_TRANSLATE_NOOP("Workbench", "Utilities")
        ], self.draft_utility_commands)

        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui",
                                             QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-archdefaults.ui",
                    QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.draftToolBar.loadedArchPreferences = True
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draft.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftsnap.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftvisual.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-drafttexts.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Arch workbench, done.\n')
Ejemplo n.º 2
0
    def Initialize(self):
        "This function is executed when FreeCAD starts"
        import BOPTools  # as bop
        import Design456_Extrude  # import all	 needed files
        import Design456_Extract
        import Design456_ExtrudeFace
        import Design456_SplitObject
        import Design456_loftOnDirection
        import Design456_Part as designPart
        import Design456_Part_Tools as pTools
        import Design456_Part_Utils as pUtils
        import Design456_2Ddrawing as TwoDDraw
        import Design456_SelectionGate as SelGate
        import Design456_Alignment as align
        # from Part import CommandShapes	 #Tube	not working
        Gui.runCommand('Std_PerspectiveCamera', 1)

        self.appendToolbar("Design456_Part", designPart.Design456_Part.list)
        self.appendToolbar("Design456_Tools", pTools.Design456_Part_Tools.list)
        self.appendToolbar("Design456_2DTools",
                           pUtils.Design456_Part_Utils.list)
        self.appendToolbar("Design456_2Ddrawing",
                           TwoDDraw.Design456_2Ddrawing.list)
        self.appendToolbar("Selection Mode",
                           SelGate.Design456_SelectionGate.list)
        self.appendToolbar("Design456_Alignments",
                           align.Design456_Alignment.list)

        self.appendMenu("Design456_Part", designPart.Design456_Part.list)
        self.appendMenu("Design456_Tools", pTools.Design456_Part_Tools.list)
        self.appendMenu("Design456_2Ddrawing",
                        TwoDDraw.Design456_2Ddrawing.list)
        self.appendMenu("Design456_2DTools", pUtils.Design456_Part_Utils.list)
        self.appendMenu("Design456_Alignments", align.Design456_Alignment.list)

        # Design456_Part
        #self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), self.drawing_commands)

        # Design456_Part
        # DRAFT
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            if Gui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError("FreeCAD and Pivy use different versions "
                                     "of Coin. "
                                     "This will lead to unexpected behavior.")
        except AssertionError:
            App.Console.PrintWarning("Error: FreeCAD and Pivy "
                                     "use different versions of Coin. "
                                     "This will lead to unexpected "
                                     "behavior.\n")
        except Exception:
            App.Console.PrintWarning("Error: Pivy not found, "
                                     "Draft Workbench will be disabled.\n")
        except Exception:
            App.Console.PrintWarning("Error: Unknown error "
                                     "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return
        # END DRAFT

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            Gui.addLanguagePath(":/translations")
            Gui.addIconPath(":/icons")
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Draft will not work as expected.\n")
        try:
            # Set up command lists
            import draftutils.init_tools as it
            self.drawing_commands = it.get_draft_drawing_commands()
            self.annotation_commands = it.get_draft_annotation_commands()
            self.modification_commands = it.get_draft_modification_commands()
            self.context_commands = it.get_draft_context_commands()
            self.line_commands = it.get_draft_line_commands()
            self.utility_commands = it.get_draft_utility_commands()
            self.utility_small = it.get_draft_small_commands()

            # Set up toolbars
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                self.drawing_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
                self.annotation_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
                self.modification_commands)
            self.appendToolbar(
                QT_TRANSLATE_NOOP("Draft", "Draft utility tools"),
                self.utility_small)

            # Set up menus
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"),
                            self.drawing_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"),
                            self.annotation_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"),
                            self.modification_commands)
            self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"),
                            self.utility_commands + self.context_commands)

            # Set up preferences pages
            if hasattr(FreeCADGui, "draftToolBar"):
                if not hasattr(Gui.draftToolBar, "loadedPreferences"):
                    Gui.addPreferencePage(":/ui/preferences-draft.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftinterface.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftsnap.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-draftvisual.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.addPreferencePage(":/ui/preferences-drafttexts.ui",
                                          QT_TRANSLATE_NOOP("Draft", "Draft"))
                    Gui.draftToolBar.loadedPreferences = True
                # END DRAFT
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Draft will not work as expected.\n")
Ejemplo n.º 3
0
    def Initialize(self):
        """When the workbench is first loaded."""
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = 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 Exception:
            FreeCAD.Console.PrintWarning("Error: Unknown error "
                                         "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            from draftguitools import gui_circulararray
            from draftguitools import gui_polararray
            from draftguitools import gui_orthoarray
            from draftguitools import gui_arrays
            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as exc:
            FreeCAD.Console.PrintError(exc)
            FreeCAD.Console.PrintError("Error: Initializing one or more "
                                       "of the Draft modules failed, "
                                       "Draft will not work as expected.\n")

        # Set up command lists
        import draftutils.init_tools as it
        self.drawing_commands = it.get_draft_drawing_commands()
        self.annotation_commands = it.get_draft_annotation_commands()
        self.modification_commands = it.get_draft_modification_commands()
        self.context_commands = it.get_draft_context_commands()
        self.line_commands = it.get_draft_line_commands()
        self.utility_commands = it.get_draft_utility_commands()

        # Set up toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                           self.drawing_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
            self.annotation_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
            self.modification_commands)

        # Set up menus
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"),
                        self.drawing_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"),
                        self.annotation_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"),
                        self.modification_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"),
                        self.utility_commands + self.context_commands)

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draft.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftsnap.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftvisual.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-drafttexts.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')
Ejemplo n.º 4
0
    def __init__(self):

        #switch to True to enable development commands
        self.dev = False

        self.menu = 1
        self.toolbar = 2
        self.context = 4
        self.group = 8

        #dictionary key = name of command / command group.
        #'gui' - locations in gui where commands are accessed, (summed bitflags)
        #'cmd' - list of commands to display
        #'group' - Tuple containing the subgroup description and type.  None/undefined if no group
        self.command_ui = {
            'Data Tools': {
                'gui': self.menu + self.toolbar,
                'cmd': ['Import Point File', 'Export Points', 'Geodata Tools']
            },
            'Surface Tools': {
                'gui': self.menu + self.toolbar + self.context,
                'cmd': ['Create Surface', 'Surface Editor', 'Create Contour']
            },
            'Section Tools': {
                'gui': self.menu + self.toolbar,
                'cmd': ['Create Guide Lines', 'Create Section Views']
            },
            'Alignment': {
                'gui': self.menu + self.toolbar + self.context,
                'cmd': [
                    'ImportAlignmentCmd',
                    'EditAlignmentCmd',
                ]
            },
            'Element Template': {
                'gui': self.menu + self.toolbar + self.context,
                'cmd': ['ViewTemplateLibrary']
            },
            'Test': {
                'gui': self.menu + self.toolbar,
                'cmd': ['BaseTrackerTest', 'BaseTrackerLinkedTest']
            },
            'Help': {
                'gui': self.toolbar,
                'cmd': ['TrailsGuide']
            },
            'Draft Tools': {
                'gui': self.toolbar,
                'cmd':
                ['Drawing Tools', 'Modification Tools', 'Utility Tools']
            },
            'Surface Editor': {
                'gui':
                self.group,
                'cmd': [
                    'Add Triangle', 'Delete Triangle', 'Swap Edge',
                    'Smooth Surface'
                ],
                'tooltip':
                'Edit selected surface',
                'type_id':
                'Mesh::Feature'
            },
            'Geodata Tools': {
                'gui':
                self.group,
                'cmd': [
                    'Import OSM Map',
                    'Import CSV',
                    'Import GPX',
                    'Import Heights',
                    'Import SRTM',
                    'Import XYZ',
                    'Import LatLonZ',
                    'Import Image',
                    'Import ASTER',
                    'Import LIDAR',
                    'Create House',
                    'Navigator',
                    'ElevationGrid',
                    'Import EMIR',
                ],
                'tooltip':
                'Geodata Tools'
            },
            'Drawing Tools': {
                'gui': self.group,
                'cmd': draft_tools.get_draft_drawing_commands(),
                'tooltip': 'Draft creation tools'
            },
            'Modification Tools': {
                'gui': self.group,
                'cmd': draft_tools.get_draft_modification_commands(),
                'tooltip': 'Draft modification tools'
            },
            'Utility Tools': {
                'gui': self.group,
                'cmd': draft_tools.get_draft_utility_commands(),
                'tooltip': 'Draft utility tools'
            }
        }

        if not self.dev:
            return

        #development commands
        self.command.ui = {
            **self.command.ui,
            **{
                'Test': {
                    'gui': self.menu,
                    'cmd': ['Command']
                }
            }
        }
Ejemplo n.º 5
0
    def Initialize(self):
        "This function is executed when FreeCAD starts"
        import BOPTools  # as bop
        import Design456_Part as designPart
        import Design456_2Ddrawing as TwoDDraw
        import Design456_Part_Tools as _tools
        import Design456_Alignment as _alignment
        import Design456_SelectionGate as SelGate
        import DirectModeling.directModelingCommands as dModeling
        import DefeaturingWB.DefeaturingTools
        import DefeaturingWB.DefeaturingCMD
        import DefeaturingWB.FuzzyTools
        import Design456Init
        from Design456Pref import Design456Preferences
        import Design456_Segmented as _segmented

        # from Part import CommandShapes     #Tube  not working
        Gui.runCommand('Std_PerspectiveCamera', 1)

        self.appendToolbar("Design456_Part", designPart.Design456_Part.list)
        self.appendToolbar("Design456 2Ddrawing",
                           TwoDDraw.Design456_2Ddrawing.list)
        self.appendToolbar("Design456_Segmented",
                           _segmented.Design456_Segmented.list)

        self.appendToolbar("Design456 Tools", _tools.Design456_Part_Tools.list)
        self.appendToolbar("Design456 Alignment",
                           _alignment.Design456_Alignment_Tools.list)
        self.appendToolbar("Selection Mode",
                           SelGate.Design456_SelectionGate.list)
        self.appendToolbar("Direct Modeling",
                           dModeling.Design456_DirectModeling.list)

        self.appendMenu("Design456_Part", designPart.Design456_Part.list)
        self.appendMenu("Design456_2Ddrawing",
                        TwoDDraw.Design456_2Ddrawing.list)
        self.appendMenu("Design456 Tools", _tools.Design456_Part_Tools.list)
        self.appendMenu("Design456 Alignment",
                        _alignment.Design456_Alignment_Tools.list)

        # Defeaturing WB  added to Design456
        self.appendToolbar("Defeaturing Tools", [
            "DefeaturingTools", "DF_SelectLoop", "refineFeatureTool",
            "DefeatShapeFeature"
        ])
        #self.appendMenu("ksu Tools", ["ksuTools","ksuToolsEdit"])
        self.appendMenu(
            "Defeaturing Tools",
            ["refineFeatureTool", "DefeaturingTools", "DF_SelectLoop"])
        self.appendToolbar("Fuzzy Tools",
                           ["FuzzyCut", "FuzzyUnion", "FuzzyCommon"])
        self.appendMenu("Fuzzy Tools",
                        ["FuzzyCut", "FuzzyUnion", "FuzzyCommon"])
        Gui.addIconPath(Design456Init.ICON_PATH)

        # Design456_Part
        # self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), self.drawing_commands)

        # Design456_Part
        # DRAFT
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            import FreeCAD
            import FreeCADGui
            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 Exception:
            FreeCAD.Console.PrintWarning("Error: Unknown error "
                                         "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            import FreeCAD
            import FreeCADGui

            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as exc:
            FreeCAD.Console.PrintError(exc)
            FreeCAD.Console.PrintError("Error: Initializing one or more "
                                       "of the Draft modules failed, "
                                       "Draft will not work as expected.\n")
        try:
            # Set up command lists
            import draftutils.init_tools as it
            self.drawing_commands = it.get_draft_drawing_commands()
            self.annotation_commands = it.get_draft_annotation_commands()
            self.modification_commands = it.get_draft_modification_commands()
            self.utility_commands_menu = it.get_draft_utility_commands_menu()
            self.utility_commands_toolbar = it.get_draft_utility_commands_toolbar(
            )
            self.context_commands = it.get_draft_context_commands()

            # Set up toolbars
            it.init_toolbar(self,
                            QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                            self.drawing_commands)
            it.init_toolbar(
                self, QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
                self.annotation_commands)
            it.init_toolbar(
                self, QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
                self.modification_commands)
            it.init_toolbar(self,
                            QT_TRANSLATE_NOOP("Draft", "Draft utility tools"),
                            self.utility_commands_toolbar)

            # Set up menus
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Drafting")],
                         self.drawing_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Annotation")],
                         self.annotation_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Modification")],
                         self.modification_commands)
            it.init_menu(self, [QT_TRANSLATE_NOOP("Draft", "&Utilities")],
                         self.utility_commands_menu)

            # Set up preferences pages
            if hasattr(FreeCADGui, "draftToolBar"):
                if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draft.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftinterface.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftsnap.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-draftvisual.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.addPreferencePage(
                        ":/ui/preferences-drafttexts.ui",
                        QT_TRANSLATE_NOOP("Draft", "Draft"))
                    FreeCADGui.draftToolBar.loadedPreferences = True

            FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')

            # END DRAFT
        except Exception as exc:
            App.Console.PrintError(exc)
            App.Console.PrintError("Error: Initializing one or more "
                                   "of the Draft modules failed, "
                                   "Design456 will not work as expected.\n")
Ejemplo n.º 6
0
    def Initialize(self):
        """When the workbench is first loaded."""

        def QT_TRANSLATE_NOOP(context, text):
            return text

        import Draft_rc
        import DraftTools
        import DraftGui
        from draftguitools import gui_circulararray
        from draftguitools import gui_polararray
        from draftguitools import gui_orthoarray
        from draftguitools import gui_arrays
        import Arch_rc
        import Arch

        # Set up command lists
        self.archtools = ["Arch_Wall", "Arch_StructureTools", "Arch_Rebar",
                          "Arch_CurtainWall","Arch_BuildingPart",
                          "Arch_Project", "Arch_Site", "Arch_Building",
                          "Arch_Floor", "Arch_Reference",
                          "Arch_Window", "Arch_Roof", "Arch_AxisTools",
                          "Arch_SectionPlane", "Arch_Space", "Arch_Stairs",
                          "Arch_PanelTools", "Arch_Equipment",
                          "Arch_Frame", "Arch_Fence", "Arch_Truss",
                          "Arch_Profile","Arch_MaterialTools",
                          "Arch_Schedule", "Arch_PipeTools",
                          "Arch_CutPlane", "Arch_CutLine",
                          "Arch_Add", "Arch_Remove", "Arch_Survey"]
        self.utilities = ["Arch_Component", "Arch_CloneComponent",
                          "Arch_SplitMesh", "Arch_MeshToShape",
                          "Arch_SelectNonSolidMeshes", "Arch_RemoveShape",
                          "Arch_CloseHoles", "Arch_MergeWalls", "Arch_Check",
                          "Arch_ToggleIfcBrepFlag", "Arch_3Views",
                          "Arch_IfcSpreadsheet", "Arch_ToggleSubs"]

        # Add the rebar tools from the Reinforcement addon, if available
        try:
            import RebarTools
        except Exception:
            pass
        else:
            class RebarGroupCommand:
                def GetCommands(self):
                    return tuple(RebarTools.RebarCommands + ["Arch_Rebar"])

                def GetResources(self):
                    _tooltip = ("Create various types of rebars, "
                                "including U-shaped, L-shaped, and stirrup")
                    return {'MenuText': QT_TRANSLATE_NOOP("Arch", 'Rebar tools'),
                            'ToolTip': QT_TRANSLATE_NOOP("Arch", _tooltip)}

                def IsActive(self):
                    return not FreeCAD.ActiveDocument is None
            FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
            self.archtools[2] = "Arch_RebarTools"

        # Set up Draft command lists
        import draftutils.init_tools as it
        self.draft_drawing_commands = it.get_draft_drawing_commands()
        self.draft_annotation_commands = it.get_draft_annotation_commands()
        self.draft_modification_commands = it.get_draft_modification_commands()
        self.draft_context_commands = it.get_draft_context_commands()
        self.draft_line_commands = it.get_draft_line_commands()
        self.draft_utility_commands = it.get_draft_utility_commands()

        # Set up toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Arch tools"), self.archtools)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), self.draft_drawing_commands)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), self.draft_annotation_commands)
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), self.draft_modification_commands)

        # Set up menus
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Arch"),
                         QT_TRANSLATE_NOOP("arch", "Utilities")],
                        self.utilities)
        self.appendMenu(QT_TRANSLATE_NOOP("arch", "&Arch"), self.archtools)

        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Creation")],
                        self.draft_drawing_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Annotation")],
                        self.draft_annotation_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Modification")],
                        self.draft_modification_commands)
        self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"),
                         QT_TRANSLATE_NOOP("arch", "Utilities")],
                        self.draft_utility_commands
                        + self.draft_context_commands)
        FreeCADGui.addIconPath(":/icons")
        FreeCADGui.addLanguagePath(":/translations")

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui", QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.addPreferencePage(":/ui/preferences-archdefaults.ui", QT_TRANSLATE_NOOP("Arch", "Arch"))
                FreeCADGui.draftToolBar.loadedArchPreferences = True
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Arch workbench, done.\n')