Adding an Image to Button Tool Bar

Adding an Image to Button Tool Bar

MarkMERZP
Participant Participant
465 Views
4 Replies
Message 1 of 5

Adding an Image to Button Tool Bar

MarkMERZP
Participant
Participant

question-fusion.png

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
0 Likes
Accepted solutions (2)
466 Views
4 Replies
Replies (4)
Message 2 of 5

j4n.vokurka
Advocate
Advocate
Accepted solution

Hello, 

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:
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C 
There it is described in detail.

Message 3 of 5

MarkMERZP
Participant
Participant

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. 

question-fusion.png

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 

0 Likes
Message 4 of 5

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

j4n.vokurka
Advocate
Advocate
Accepted solution

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.