[BUG] UserInterface.allToolbarPanels does not yield ALL panels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey, me again. I have been making an improved ui to file command when i noticed that some of the panels under quite a few workspaces were referencing an object that I did not already have by using ui.allToolbarPanels. I wrote a quick script and sure enough, many panels are included under workspaces but are not returned by ui.allToolbarPanels.
To investigate the problem, i created a script that output a list of all panels and then all workspaces with their panels that are not included in the list of all panels. The code is:
def CheckProduct(obj:adsk.core.Workspace):
try: return obj.toolbarPanels and (obj.productType != '')
except: return False #Tying to get its panels can throw an error
def TryGet(collection):
for I in range(len(collection)):
try:
colItem = collection.item(I)
if not isinstance(colItem, (adsk.core.Workspace,adsk.core.ToolbarTab)) or CheckProduct(colItem):
yield colItem
except:pass
allPanels = [panel.id for panel in TryGet(ui.allToolbarPanels)]
validWorkspaces = [workspace for workspace in TryGet(ui.workspaces)]
allWorkspacePanels = {workspace.id: [panel.id for panel in TryGet(workspace.toolbarPanels)
if panel.id not in allPanels]
for workspace in validWorkspaces}
ui.messageBox(str({
'All Panels':allPanels,
'Workspace Panels':allWorkspacePanels}))
The code will create a list of all panel id's from ui.allToolbarPanels. Next it will iterate over each valid workspace, and create a list of all of its panels which are not in the ui.allToolbarPanels list. Lastly, it stores the id of the workspace and its panel ids in a dictionary and combines that in a list with the list of all panels which is converted into a string and output in a ui messagebox because I can copy that output, put it into vsCode, and treat it as json data to format it.
You can see the output in a gist i posted.