Setting UserParameter.expression sporadically slows down
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been having issues with a script sporadically running very slowly.
I've narrowed it down to a test where this is the entirety of the run() method:
app = adsk.core.Application.get()
design = adsk.fusion.Design.cast(app.activeProduct)
for param in design.allParameters[:10]:
# print(param.name, param.objectType, param.expression)
param.expression = param.expression + ' '
print('Done')
Even with just 10 items, sometimes the UI goes black, and it takes 30 seconds to run this.
I'm setting the param expression so that it doesn't actually change value here, to see if it was something to do with the model resizing.
What's even harder to understand is that this is fast sometimes, especially when run the first few times. Then, all of a sudden, it just runs at less than a 10th of the speed.
I even tried removing the print statement in the loop, in case that was somehow blocking the thread.
EDIT - I'm not even sure it's anything to do with params. Just suddenly even getting to the first line of the script slows down.