Hi @a.g.ashwood ,
You can create an AddIn for it.
Here is the code for it:
import adsk, adsk.core, adsk.fusion, adsk.cam, traceback
app = adsk.core.Application.get()
ui = app.userInterface
WORKSPACE_ID = 'FusionSolidEnvironment'
TOOLBARTAB_ID = "ToolsTab"
TOOLBARPANEL_ID = "SolidScriptsAddinsPanel"
CMD_ID = "Test"
_handlers = []
def run(context):
global _handlers
cmdDef = ui.commandDefinitions.itemById(CMD_ID)
if not cmdDef:
cmdDef = ui.commandDefinitions.addButtonDefinition(CMD_ID, CMD_ID, CMD_ID, ".\\")
onCommandCreated = scriptExecuteHandler()
cmdDef.commandCreated.add(onCommandCreated)
_handlers.append(onCommandCreated)
workspace = ui.workspaces.itemById(WORKSPACE_ID)
toolbar_tab = workspace.toolbarTabs.itemById(TOOLBARTAB_ID)
panel = toolbar_tab.toolbarPanels.itemById(TOOLBARPANEL_ID)
control = panel.controls.addCommand(cmdDef)
control.isPromoted = True
def stop(context):
global _handlers
_handlers = []
try:
ui.commandDefinitions.itemById(CMD_ID).deleteMe()
except:
pass
workspace = ui.workspaces.itemById(WORKSPACE_ID)
toolbar_tab = workspace.toolbarTabs.itemById(TOOLBARTAB_ID)
panel = toolbar_tab.toolbarPanels.itemById(TOOLBARPANEL_ID)
try:
panel.controls.itemById(CMD_ID).deleteMe()
except:
pass
class scriptExecuteHandler(adsk.core.CommandCreatedEventHandler):
def __init__(self):
super().__init__()
def notify(self, eventArgs: adsk.core.CommandCreatedEventArgs) -> None:
# TODO: your script goes here!!!
app.log(f'{eventArgs.firingEvent.sender.name} executed!')
You need to place your script in scriptExecuteHandler.notify() to be run when you click on the button.
For this case the button is created under Design workspace > Utilities tab > AddIns pannel. You can change its place where it'd be more convenient for you.
Hope this could help.
Regards,
Jorge Jaramillo