Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm struggling with the ToolbarPanels.add Method ( https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-165e8619-babe-4448-a79b-ff7d5dfac8aa )
My icon for my button is not showing up:-
I've got a ./resources folder with 32x32.png and 64x64.png etc in it, but I can't work out how I tell the ".add" method to *use* them - here's my code. I did manage to figure it out for the commands, but that's becuase those methods let you tell it where the resource folder is - how do I tell ToolbarPanels.add this?
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', 'AirFoil Tools', 'SelectPanel', False) # This fails to put any button onto my new panel item.
# 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', 'Import DAT', 'Load and optimise a dat to a spline', './resources') # This works, with its own tiny button.
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()))
Solved! Go to Solution.