Bug when getting toolbar panel names from Sketch Toolbar Tab in the Design Workspace

Bug when getting toolbar panel names from Sketch Toolbar Tab in the Design Workspace

robertASTUP
Contributor Contributor
647 Views
4 Replies
Message 1 of 5

Bug when getting toolbar panel names from Sketch Toolbar Tab in the Design Workspace

robertASTUP
Contributor
Contributor

Hi, I wrote a tiny script for getting the name of each toolbar panel from each toolbar tab in the design workspace as follows:

# Script to get all toolbar tabs in the active workspace and write them to a file for RAG to read.

import adsk.core

app = adsk.core.Application.get()
ui = app.userInterface

tab = ui.activeWorkspace.toolbarTabs.itemById("SurfaceTab")

toolbar_panels = tab.toolbarPanels
for tbp in toolbar_panels:
    print(tbp.name)

 

This script works perfectly for all (visible) toolbar tabs in the Design workspace except for the Surface toolbar tab where the following error is found:

 

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 11, in <module>
  File "/Users/robertdickson/Library/Application Support/Autodesk/webdeploy/production/e379c5f768f16e4cbcd81b81fe59a8562f304f19/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/core.py", line 18710, in __iter__
    yield self.item(i)
          ^^^^^^^^^^^^
  File "/Users/robertdickson/Library/Application Support/Autodesk/webdeploy/production/e379c5f768f16e4cbcd81b81fe59a8562f304f19/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/core.py", line 18744, in item
    return _core.ToolbarPanels_item(self, index)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : item

Weirdly it seems to be able to get the "Create" and "Modify" Panels before failing.

 

Please could this error be addressed?

 

Thanks!

 

Robert

0 Likes
648 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor

Hi @robertASTUP -San.

 

There seems to be something present that is not being displayed.

Try the following modification and execute it.

・・・
        toolbar_panels = tab.toolbarPanels
        # for tbp in toolbar_panels:
        #     print(tbp.name)

        for idx in range(len(toolbar_panels)):
            try:
                tbp = toolbar_panels[idx]
                print(tbp.name)
            except:
                print(f"error - index:{idx}")
0 Likes
Message 3 of 5

robertASTUP
Contributor
Contributor

-

0 Likes
Message 4 of 5

robertASTUP
Contributor
Contributor

Hi, thanks for your reply. This unfortunately produces the same error. The error still occurs at line 6 of your code and is a problem with the generator. I can see from the other toolbar tabs and panels printed that it is a problem with the "Assemble" toolbar panel in the "Surface" toolbar tab. For information that may be useful, I am on the latest version of Fusion 360 on MacOS.

Message 5 of 5

john.kirchner
Autodesk
Autodesk

Hello - just wanted to inform you that this has been identified as a bug and should be fixed in an upcoming release (probably not the next one). Thank you for posting!

In the meantime, you can work around this issue utilizing array iteration and checking if panel is null. Something like:

for index in range(toolbar_panels.count):
    tbp = toolbar_panels[index]
    if tbp:
        app.log(tbp.name)