Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've pasted in some code below. I have this code in the Run procedure for each of my Add-Ins. Problem is the Add-Ins are added, on startup, in alphabetical order and I do not want my icons to appear in this order. I want to set the order. I see there is an index function but it is read only. Is there a way to do this?
Thanks in advance for the help.
Eric
def run(context):
"""The run function is the main function that runs first when loading the Add-in.
It will add a toolbar button to the ui which will be controlled by the comPressedEventHandler class functions."""
ui = None
global units
try:
#get the application
app = adsk.core.Application.get()
ui = app.userInterface
#Get command definitions & design workspace##################################################################################################
cmd_def = ui.commandDefinitions
des_wp = ui.workspaces.itemById('FusionSolidEnvironment')
# Add the Eco Tab to the Workspace.
eco_tab = des_wp.toolbarTabs.itemById(eco_Tab)
if not eco_tab:
eco_tab = des_wp.toolbarTabs.add(eco_Tab, eco_Tab_Name)
# Add the Tray Design panel.
addin_panel = eco_tab.toolbarPanels.itemById(eco_Panel)
if not addin_panel:
addin_panel = eco_tab.toolbarPanels.add(eco_Panel, eco_Panel_Name,eco_tab.id, False)
#Get command definitions & design workspace##################################################################################################
#Add a button CommandDefininition to that collection
# folder name (within same directory) for icons 16X16, 32X32 & 64X64.png) (change button properties in global variables on top)
# ret = readConstants("RevisionNumber.txt")
comDef = cmd_def.itemById(butName)# + " Rev " + ret[0][1]#this goes after butDialogName
if not comDef:
comDef = cmd_def.addButtonDefinition(butName,
butDialogName,
tooltip,
folderName)
#Grabbing the correct toolbar panel to add the button to
addinsToolbarPanel = addin_panel
#Adding the button to the toolbar Panel
tray_ctrl = addin_panel.controls.itemById(butName)
if not tray_ctrl:
tray_ctrl = addinsToolbarPanel.controls.addCommand(comDef,controlName)
#Making the button visible without having to use the dropdown
tray_ctrl.isPromotedByDefault = True
#Setting up the handler if the button is pressed
#Calling the class
comPressed = comPressedEventHandler()
comDef.commandCreated.add(comPressed)
handlers.append(comPressed)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.