- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, i have been working on a pretty massive project and have found myself in a situation where making any changes to the location of a toolbarPanel, results in the old panel sill being left behind when i add the command to the new location. Ive parsed all of the ui after cleaning the first panel, and that clearly says no command definition, command control, nor toolbar panel is left over. However, once i restart the addin that defines a new location, the old panel shows up along with the new one and both reference the same panel index. Ive noticed that many panels are referenced multiple times in different tabs like the "SelectPanel":index 38. I imagine the tabs are tracking panel ids on a higher level not documented in the api. Is there any way to tell a toolbarTab to forget ever having created the panel so i can add it to different locations without restarting f360?
I could attempt to create a dummy panel with a different id/index and then delete that to break the link, but id really rather have a more clean method.'
Is it as simple as me not deleting everything properly? I have maintained a list of any ui objects i create and call "delete me" on each of them. Any help would be greatly appreciated.
Ive included my run function below, its part of a massive project and is found inside of a class which is why there are "self." calls in it.
def run(self, *args):
"""Function is run when the addin starts. Use the onCreate function instad!
Important! If overridden ensure to execute with super().on_run()"""
global customTab, customPannel, createdObjects
with ErrorCatcher(True):
ui = AppObjects().ui
designWorkspace = ui.workspaces.itemById('FusionSolidEnvironment')
def NewTab(id, Name = 'No Name Provided'):
newDesignTab = None
newDesignTab = designWorkspace.toolbarTabs.itemById(id)
if newDesignTab == None:
newDesignTab = designWorkspace.toolbarTabs.add(id, str(Name))
createdObjects.append(newDesignTab)
return newDesignTab
def NewPanel(tab:core.ToolbarTab, id, Name = 'No Name Provided'):
allNewDesignTabPanels = tab.toolbarPanels
brandNewDesignPanel = None
brandNewDesignPanel = allNewDesignTabPanels.itemById(id)
if brandNewDesignPanel is None:
brandNewDesignPanel = allNewDesignTabPanels.add(id, Name)
createdObjects.append(brandNewDesignPanel)
return brandNewDesignPanel
def NewControl(controls : core.ToolbarControls, id, anotherExtrudeCmd):
if anotherExtrudeCmd:
# Go ahead and add the command to the panel:
extrudeCmdControl = None
extrudeCmdControl = controls.itemById(id)
if extrudeCmdControl == None :
extrudeCmdControl = controls.addCommand(anotherExtrudeCmd)
if extrudeCmdControl:
extrudeCmdControl.isVisible = True
extrudeCmdControl.isPromoted = True
extrudeCmdControl.isPromotedByDefault = True
if id == 'Extrude': ui.messageBox('Do you see Best Design Panel now?')
createdObjects.append(extrudeCmdControl)
return extrudeCmdControl
def NewDefinition(cmdID, cmdName, cmdDes, cmdIcon):
commandDefinition = None
commandDefinition = ui.commandDefinitions.itemById(cmdID)
if not commandDefinition:
commandDefinition = ui.commandDefinitions.addButtonDefinition(cmdID, cmdName, cmdDes, cmdIcon)
createdObjects.append(commandDefinition)
return commandDefinition
newDesignTab = None
brandNewDesignPanel = None
extrudeCmdControl = None
# newDesignTab = NewTab('ToolsTab', 'Tools')
newDesignTab = NewTab('SolidTab', 'Solid')
# newDesignTab = NewTab('NewDesignTabHere', 'New Design Tab')
if newDesignTab != None:
brandNewDesignPanel = NewPanel(newDesignTab, 'bestDesignPanelEverId', 'Best Design Panel')
if brandNewDesignPanel != None:
newDesignTab.activate()
if newDesignTab.isActive:
extrudeCmdControl = NewControl(brandNewDesignPanel.controls, 'Extrude', ui.commandDefinitions.itemById('Extrude'))
self.commandDefinition = NewDefinition(self.commandID, self.commandName, self.commandDescription, self.commandIcon)
cmdTab = NewTab(self.toolbarTabID, self.toolbarTabName)
cmdPanel:core.ToolbarPanel = NewPanel(cmdTab, self.toolbarPanelID, self.toolbarPanelName)
self.control = NewControl(cmdPanel.controls, self.commandControlID, self.commandDefinition)
Solved! Go to Solution.