Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create control in ToolBar

1 REPLY 1
SOLVED
Reply
Message 1 of 2
raterWBBQB
673 Views, 1 Reply

Create control in ToolBar

sk.PNGHow do this?

1 REPLY 1
Message 2 of 2
erik
in reply to: raterWBBQB

There are two things to do, if you want to create a button in the toolbar like the image you posted.

 

1. You will need to add a Panel to the toolbar

 

Here is a post from the forum showing you how to add a new Panel to the toolbar in the Model environment

 

app = adsk.core.Application.get()
ui  = app.userInterface
        
workSpace = ui.workspaces.itemById('FusionSolidEnvironment')
tbPanels = workSpace.toolbarPanels
        

tbPanel = tbPanels.itemById('NewPanel')
if tbPanel:
      tbPanel.deleteMe()
tbPanel = tbPanels.add('NewPanel', 'New Panel', 'SelectPanel', False)

 

2. You will need to add a control (Button) to the panel and a command (Button attributes) to the control

 

The second part of the run method from the above mentioned post shows how to do so

 

cmdDef = ui.commandDefinitions.itemById('NewCommand')
if cmdDef:
    cmdDef.deleteMe()
cmdDef = ui.commandDefinitions.addButtonDefinition('NewCommand', 'Dimensions', 'Demo for new command', './resources')
tbPanel.controls.addCommand(cmdDef)

 

Two other things to mention

  1. If one does not add a command to the panel it will not be visible.
  2. If one does not have a folder named 'resources' a questionmark will be used as the button icon

 

Hope this helps.

 

- Erik

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report