When running a Python Script, Fusion goes into "Not Responding" mode until the script finishes

When running a Python Script, Fusion goes into "Not Responding" mode until the script finishes

owendelong
Contributor Contributor
948 Views
4 Replies
Message 1 of 5

When running a Python Script, Fusion goes into "Not Responding" mode until the script finishes

owendelong
Contributor
Contributor

Despite my script having a progress report that should update every second, and output to the TextCommandPallette, the script will run for several seconds before groups of output and the latest Progress are displayed and the Fusion UI (including the cancel button in the Progress Window) is unresponsive until the script completes.

 

The script creates a sketch and then draws a rectangle and several hundred (maybe upwards of 3000) small line segments and creates a number of "multiline" text objects (which actually only contain 1-2 characters).

 

The eventual intent of the script is to be a generator for DXF files that can be used to laser cut a variety of rulers in wood or acrylic.

 

The code frequently checks for the cancel button being clicked, which I thought should return control to the UI briefly to sample the cancel button at least, but it seems like Fusion is basically stuck in a wait() for the Python script to finish (I don't know if that is what is actually happening).

 

The script is long, but I can post it if people feel it is necessary to identify the problem/solution. I'm hoping someone is already familiar with this behavior and its resolution from the description.

 

 

0 Likes
Accepted solutions (1)
949 Views
4 Replies
Replies (4)
Message 2 of 5

owendelong
Contributor
Contributor

I should add this is on a Mac.

0 Likes
Message 3 of 5

jeff.pek
Community Manager
Community Manager
Accepted solution

If you could post your script, that would be very helpful. In a script that takes significant time to execute, it's important to give Fusion a chance to do its work. Usually, this is done with calls to adsk.doEvents.

 

Jeff

Message 4 of 5

owendelong
Contributor
Contributor

Let me try adding calls to adsk.doEvents and see if that resolves it. If that works, I'll note it in a reply and mark that as an accepted solution. If not, I'll post the script. Thanks!

 

0 Likes
Message 5 of 5

owendelong
Contributor
Contributor

That solved the problem, indeed. This should be included in more of the example code and explained better in the documentation, IMHO.

0 Likes