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')
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")
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')