- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am trying to update the icon of a button in my addon. But when i set the .resourceFolder property, the icon does not update. If I reset the panel customization, the icon updates, or if I remove it from the panel and then put it back, it will also update. Am I missing something?
import adsk.core,os
from ...lib import fusion360utils as futil
app = adsk.core.Application.get()
ui = app.userInterface
filePath = os.path.join(os.path.dirname(os.path.abspath(__file__)))
iconPath1 = os.path.join(filePath,"icon1")
iconPath2 = os.path.join(filePath,"icon2")
buttonFunction = 1
def command_created(args: adsk.core.CommandCreatedEventArgs):
if buttonFunction == 1:
args.command.parentCommandDefinition.resourceFolder = iconPath2
futil.add_handler(args.command.execute, command_1)
futil.add_handler(args.command.destroy, command_destroy)
else:
args.command.parentCommandDefinition.resourceFolder = iconPath1
futil.add_handler(args.command.execute, command_2)
futil.add_handler(args.command.destroy, command_destroy)
def command_1(args: adsk.core.CommandEventArgs):
app.log("switching to icon 2")
app.log(f"{iconPath2}")
args.command.parentCommandDefinition.resourceFolder = iconPath2
def command_2(args: adsk.core.CommandEventArgs):
app.log("switching to icon 1")
app.log(f"{iconPath1}")
args.command.parentCommandDefinition.resourceFolder = iconPath1
def command_destroy(args: adsk.core.CommandEventArgs):
global buttonFunction
if buttonFunction == 1:
buttonFunction = 2
else:
buttonFunction = 1
Solved! Go to Solution.