Create control in ToolBar

Create control in ToolBar

Anonymous
Not applicable
877 Views
1 Reply
Message 1 of 2

Create control in ToolBar

Anonymous
Not applicable

sk.PNGHow do this?

Accepted solutions (1)
878 Views
1 Reply
Reply (1)
Message 2 of 2

erik
Advocate
Advocate
Accepted solution

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