import os import FreeCADGui as Gui import FreeCAD as App import ahb_locator global ahb_icon ahb_icon = os.path.join(os.path.dirname(ahb_locator.__file__), "resources/assembly-handbook.svg") class AssemblyHandbookWorkbench(Gui.Workbench): """ class which gets initiated at startup of the gui """ MenuText = "Assembly handbook" ToolTip = "A workbench for automating creation of an assembly handbook" Icon = ahb_icon toolbox = [] def GetClassName(self): return "Gui::PythonWorkbench" def Initialize(self): """ This function is called at the first activation of the workbench. here is the place to import all the commands """ #from freecad.assembly_handbook import my_numpy_function #App.Console.PrintMessage("switching to workbench_starterkit\n") #App.Console.PrintMessage("run a numpy function: sqrt(100) = {}\n".format(my_numpy_function.my_foo(100))) self.appendToolbar("Tools", self.toolbox) self.appendMenu("Tools", self.toolbox) def Activated(self): """ code which should be computed when a user switch to this workbench """ pass def Deactivated(self): """ code which should be computed when this workbench is deactivated """ pass Gui.addWorkbench(AssemblyHandbookWorkbench()) print("Assembly Handbook workbench GUI loaded")