Command Shortcut Not Appearing in Toolbar for Custom Add-In

Command Shortcut Not Appearing in Toolbar for Custom Add-In

valtteri_saarinen_vs
Participant Participant
366 Views
3 Replies
Message 1 of 4

Command Shortcut Not Appearing in Toolbar for Custom Add-In

valtteri_saarinen_vs
Participant
Participant

Hi everyone,

99% of python code is created by ChatGPT.  I'm working on a custom Fusion 360 add-in that creates an RHS (Rectangular Hollow Section) profile in the Sketch environment. The add-in works correctly in terms of functionality, but the custom command shortcut doesn't appear in the toolbar as expected.

Here are the details of what I've done:

I added the command to the SolidScriptsAddinsPanel using the following code:

 

panel = ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
panel.controls.addCommand(command_def)

 

The command_def is created with a button definition, and an icon is provided:

 

command_def = ui.commandDefinitions.addButtonDefinition(
'createRHSProfile',
'RHS Profile Creation',
'Creates a sketch of an RHS profile',
'resources/createProfileIcon.png'
)

 

The resources folder is in the same directory as my add-in, and the icon file createProfileIcon.png is 64x64 pixels and in PNG format.

I verified that the add-in is running successfully through the Add-ins Manager, and the functionality works as expected. However, the shortcut still doesn’t appear on the toolbar.

 

Could someone help me understand why the shortcut isn’t appearing in the toolbar? Is there an additional step or setting required to make it visible?

 

Thanks in advance for your assistance!

 

0 Likes
367 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @valtteri_saarinen_vs -San.

 

The fourth argument of addButtonDefinition is the folder path, not the file path.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-04eb6198-72cd-4430-a6a4-8d68a1105b8e 


The image file name should be “32x32.png” or something similar.

0 Likes
Message 3 of 4

valtteri_saarinen_vs
Participant
Participant

Hello.

Here is python code for RHS Profile generator. If you have time to check it out. I can't get shortcut to appear in toolbar. Python code "comments" are Finnish

0 Likes
Message 4 of 4

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

The add_command() function, which add the button to the menu, is not being call anywhere in your code.

Take into account, like @kandennti said, the icons name should 16x16.png or 32x32.png.

This Fusion's User Interface Customization document (https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C) is worth reading.

 

Regards,

Jorge

 

0 Likes