Add control to toolbar panel

<?xml encoding=”UTF-8″>It’s worth downloading existing apps from the Fusion 360 exchange store even just to see if they already implement a certain functionality that you are interested in. In which case you can look at the source code (if it’s a JavaScript or Python add-in) and see how things are done.

E.g. the ExactFlat add-in creates its own toolbar panel and promotes its single button control to that panel.

Exactflat

It’s done using this part of the Python code:

# "toolbarControlPanel_" is the button control added to the panel
toolbarControlPanel_.isPromoted = True
toolbarControlPanel_.isPromotedByDefault = True

isPromoted = True will make the control show up on the panel – just like when clicking the curved arrow (Add to toolbar) on a control in a panel menu:

Addtotoolbar

But if the user clicks Reset Panel Customization on the given panel or Reset All Toolbar Customization anywhere on the toolbar then the button will disappear from the panel.   

Reset_toolbar

isPromotedByDefault = True will make sure that the button stays on the panel even if the toolbar is reset using either of the above mentioned ways.


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading