framework/sequence_generation/Init.py
2024-03-24 15:26:20 +03:00

79 lines
No EOL
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import FreeCAD
import FreeCADGui
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
FreeCADGui.addCommand(, my_function1)
class MyWorkbenchGui:
def Initialize(self):
# Словарь с именами функций и путями к иконкам
commands_dict = {
"MyCommand1": (my_function1, "Path/to/icon1.svg"),
"MyCommand2": (my_function2, "Path/to/icon2.svg")
}
# Регистрация команд и иконок
register_commands(commands_dict)
# Создание панели инструментов и добавление команд с иконками
self.appendToolbar("My Tools", [("MyCommand1", "MyCommand1_icon"), ("MyCommand2", "MyCommand2_icon")])
def appendToolbar(self, toolbar_name, commands):
toolbar = FreeCADGui.ToolBar(toolbar_name)
for cmd, icon in commands:
toolbar.appendCommand(cmd, icon)
class MyWorkbench:
def __init__(self):
self.__class__.Icon = FreeCAD.getHomePath() + "Path\\to\\icon.svg"
self.__class__.MenuText = "Assembly Structure Analysis"
self.__class__.ToolTip = "Workbench made for structure analysis and assembly planning"
def GetClassName(self):
return "Gui::AsmSAWorkbench"
def Initialize(self):
# Create toolbar
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" ])
# Create menu
# self.appendMenu("My Menu", ["MySubMenu1", "MySubMenu2"])
def Activated(self):
# Code to run when the workbench is activated
pass
def Deactivated(self):
# Code to run when the workbench is deactivated
pass
def GetResources(self):
return {'Pixmap': self.__class__.Icon, 'MenuText': self.__class__.MenuText, 'ToolTip': self.__class__.ToolTip}
def appendToolbar(self, toolbar_name, commands):
toolbar = FreeCADGui.ToolBar(toolbar_name)
for cmd in commands:
toolbar.appendCommand(cmd)
def appendMenu(self, menu_name, commands):
menu = FreeCADGui.Menu(menu_name)
for cmd in commands:
menu.appendCommand(cmd)
# Create instance of the workbench
my_workbench = MyWorkbench()
# Register the workbench with FreeCAD
FreeCADGui.addWorkbench(my_workbench)