Hi,
The addin below demonstrates how to create a new toolbar panel.
import adsk.core, adsk.fusion, adsk.cam, traceback
tbPanel = None
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
workSpace = ui.workspaces.itemById('FusionSolidEnvironment')
tbPanels = workSpace.toolbarPanels
global tbPanel
tbPanel = tbPanels.itemById('NewPanel')
if tbPanel:
tbPanel.deleteMe()
tbPanel = tbPanels.add('NewPanel', 'New Panel', 'SelectPanel', False)
# Empty panel can't be displayed. Add a command to the panel
cmdDef = ui.commandDefinitions.itemById('NewCommand')
if cmdDef:
cmdDef.deleteMe()
cmdDef = ui.commandDefinitions.addButtonDefinition('NewCommand', 'New Command', 'Demo for new command')
tbPanel.controls.addCommand(cmdDef)
ui.messageBox('Hello addin')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def stop(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
if tbPanel:
tbPanel.deleteMe()
ui.messageBox('Stop addin')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Thanks,
Jack