Back thinking about this.
So, the post macro writes the definition of the custom macro to the parameters.
So, the command manager has a different version of what is current?
Back thinking about this.
Code: Select all
custom_toolbar = FreeCAD.ParamGet(
"User parameter:BaseApp/Workbench/Global/Toolbar/MyCustomToolbar"
)
command_name = FreeCADGui.Command.createCustomCommand(
"MyGreatMacro.FCMacro",
"Menu text here",
"This is a tooltip",
"This is the what's this text",
"This is the status tip",
"icon_file.xpm",
)
custom_toolbar.SetString(command_name, "FreeCAD")
# Force the toolbars to be recreated
wb = FreeCADGui.activeWorkbench()
wb.reloadActive()
I my mind I'm trying to mimic the process of a user creating one or more "commands" in the Tools>Customize, Macros tab.chennes wrote: ↑Wed Sep 28, 2022 7:56 pm Only a tiny bit of the Addon Manager code there is really relevant to your case: the FreeCADGui.Command.createCustomCommand is the real workhorse, everything around it is mostly UI niceties so the user can place the buttons where they want them. I'm happy to explain individual bits if it would help, but overall what you need is probably just something like:Code: Select all
custom_toolbar = FreeCAD.ParamGet( "User parameter:BaseApp/Workbench/Global/Toolbar/MyCustomToolbar" ) command_name = FreeCADGui.Command.createCustomCommand( "MyGreatMacro.FCMacro", "Menu text here", "This is a tooltip", "This is the what's this text", "This is the status tip", "icon_file.xpm", ) custom_toolbar.SetString(command_name, "FreeCAD") # Force the toolbars to be recreated wb = FreeCADGui.activeWorkbench() wb.reloadActive()
Code: Select all
custom_toolbar = FreeCAD.ParamGet("User parameter:BaseApp/Workbench/Global/Toolbar/MyCustomToolbar")
command_name = FreeCADGui.Command.createCustomCommand(
"Snip.FCMacro",
"Screen cap",
"This is a tooltip",
"This is the what's this text",
"This is the status tip",
"camera-photo.svg",)
custom_toolbar.SetString(command_name, "FreeCAD")
# Force the toolbars to be recreated
wb = FreeCADGui.activeWorkbench()
wb.reloadActive()
Interesting note, reference last post. Every time I open Tools>Customize, Toolbars tab, Global. Another blank Custom_# command is created consuming the contents of the lesser numbered Custom_#.