RuntimeError: 2 : InternalValidationError : found when attempting to access a selectedItem's index
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My plugin has a dropdown whose options depend on the value of another input. I have a top-level handler that listens to all changes, and computes any changes necessary (such as updating the dropdown's items).
The code to reset the dropdown looks like the following:
dropdown.listItems.add(replacement_text, True) # To get rid of the previously-selected option's text.
dropdown.listItems.clear()
for option in new_options:
dropdown.listItems.add(option, False)
When I later change the dropdown's selection in the UI, I get the following error. `item` here is obtained from `dropdown.selectedItem`, first checking to make sure that it is not None:
File "/Users/perry/Library/Application Support/Autodesk/Autodesk Fusion 360/API/AddIns/ManufacturingSustainabilityInsights/commands/mainDialog/process_picker.py", line 66, in value
futil.log(f"{item.index}")
^^^^^^^^^^
File "/Users/perry/Library/Application Support/Autodesk/webdeploy/production/888e96fb45af0b2b166284da26f51796edcd6a6b/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/core.py", line 11306, in _get_index
return _core.ListItem__get_index(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : found
Furthermore, Fusion has been crashing frequently while testing. It seems nondeterministic at times, but one way I've been able to consistently reproduce it is by adding the following snippet to my dropdown-clearing code:
if dropdown.selectedItem is not None:
dropdown.selectedItem.isSelected = False
One more curious thing: It seems my handler that handles UI updates in being called twice when I select something in the dropdown. The first time succeeds, the second time triggers the error.
My current thoughts:
1. Is it possible that the onInputChanged event happens when the code updates an input's value, or is it only for user inputs?
2. Am I just going about things in the wrong way?
3. Are there logs or something that I could check for info when autodesk crashes completely?
Any help or advice would be much appreciated!