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 __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'] } } }
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): """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')