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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding an Image to Button Tool Bar

Message 1 of 5
195 Views, 4 Replies

Adding an Image to Button Tool Bar


I was wondering how to add an image to a button. The default image is a question mark and I was wondering how to replace it with my own. 


Here is the command I am using: 

cmdDef = ui.commandDefinitions.addButtonDefinition(CMD_ID, CMD_ID, CMD_ID,resourceFolder= "")
I found where the resource folder is for this command it contains 4 images (3 default & 1 of my own): 
Default: 16x16png, 32x32.png, and 64x64.png
My image: TD.png
I'm trying to use the TD.png but I am not sure how to call it.
Wondering if someone could explain how I can call the image. Again, the image i am trying to use is in the same folder as the command resource folder. 
Thank you
Message 2 of 5
in reply to: MarkMERZP


just replace the default ones with your icons. For the image you have to define a resource folder where the icons are located using in this case the .addButtonDefinition(). Then you just paste the icons into the resource folder and name them as they're named in the folder you found, hence your 32x32 icon should be named 32x32.png, 64x64 icon 64x64.png and so on.


Fusion will use the differently sized icons automatically so you don't have to worry about other management. There are also icons you can add for different states of the command like disabled etc. Try to take a look at the User-Interface Customization article: 
There it is described in detail.

Message 3 of 5
in reply to: j4n.vokurka

Gotcha, I'm just unsure on how to call the resource folder my icons are located. I created 3 .png's with the names required by fusion to read, each with the correct sizing; 16x16.png,32x32.png, and 64x64.png. I replaced the stock images in the folder with my images. I'm just unsure on what to call. I looked into the link you provided and it did bring some clarity on how to use it but I am still "stuck." Here is the paths that are shown in my VSCode that I am currently working in. 


The .png's shown are the images I want to use since I had to rename them to what fusion reads.


Thank you for your help 

Message 4 of 5
in reply to: MarkMERZP

I got the command to work, thank you for your help. It ended up being a typo on my end.
Message 5 of 5
in reply to: MarkMERZP

You can use relative or absolute path to determine the location of the resource folder. If the add-in is to be used by somebody else it's best to use relative path so it won't cause a crash.

Different images of buttons will each have their own folder where you store the differently sized icon files.

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