import FreeCAD import FreeCADGui def register_commands(commands_dict): for cmd_name, (func, icon_path) in commands_dict.items(): FreeCADGui.addCommand(cmd_name, func) FreeCADGui.addIcon(cmd_name + "_icon", icon_path) class MyWorkbenchGui: def Initialize(self): pass def InitGui(self): # Словарь с именами функций и путями к иконкам commands_dict = { 'Check Model': (my_function1, "Path/to/icon1.svg"), 'Constraints Autogeneration': (my_function2, "Path/to/icon2.svg"), 'Constraints Editing': (my_function1, "Path/to/icon1.svg"), 'Generate AdjMatrix': (my_function1, "Path/to/icon1.svg"), 'Generate Relationship Matrix': (my_function1, "Path/to/icon1.svg"), 'Clusterisation': (my_function1, "Path/to/icon1.svg"), 'StepByStepClusterisation': (my_function1, "Path/to/icon1.svg"), 'Generate Assembly Sequences': (my_function1, "Path/to/icon1.svg"), 'Decomposition Step': (my_function1, "Path/to/icon1.svg") } # Регистрация команд и иконок register_commands(commands_dict) # Создание панели инструментов и добавление команд с иконками self.appendToolbar("Preprocessing", ["Check Model", "Constraints Autogeneration", "Constraints Editing"]) self.appendToolbar("Analysis", ["Generate AdjMatrix", "Generate Relationship Matrix", "Clusterisation", "StepByStepClusterisation"]) self.appendToolbar("AssemblySequence", ["Generate Assembly Sequences", "Decomposition Step" ]) def appendToolbar(self, toolbar_name, commands): toolbar = FreeCADGui.ToolBar(toolbar_name) for cmd, icon in commands: toolbar.appendCommand(cmd, icon) # Создание экземпляра верстака GUI my_workbench_gui = MyWorkbenchGui() # Регистрация верстака FreeCADGui.addWorkbench(my_workbench_gui)