Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Restart Fusion's Python Environment

scruffmeister
Participant

Restart Fusion's Python Environment

scruffmeister
Participant
Participant

Hi,

 

During development of a reasonably complex script using multiple Python files, I am finding that when I make changes to method and object signatures I have to restart Fusion for it to pickup the changes. My project source is organised into folders under the script directory. Simple code changes within existing methods are picked up as you would expect.

 

I assume this behaviour is the consequence of some caching in the Python environment which is run by Fusion, whose lifetime spans script executions. Is there a way to force a restart/reload of Fusion's Python environment so that refactoring changes can be picked up without having to restart the entire Fusion application?

 

Thank you.

0 Likes
Reply
735 Views
6 Replies
Replies (6)

0xHexdec
Contributor
Contributor

Sems strange to me, as I havn't had this problem before. How to you restart your script? Do you use the debugger connected to Fusion to restart it, as this should make sure the project is up-to-date.

Do you load modules dynamically?

Dumb question, but if you use vscode, did you make sure to save the changes before running the script?

0 Likes

borrinboing
Observer
Observer

Hey, scruffmeister

I was having the exact same problem. It was a lot of frustration trying to fix a bug in my module before I realised my changes weren't being instantiated when re-running my original script... No idea why Fusion operates like this...

 

It's not elegant, but the work around I'm using is to have:

import importlib
import myModule
importlib.reload(myModule)

importlib allows you to forcibly reload modules and this will have to do while developing myModule.

Hope that helps.

 

I'm an OSX user, are you? It might be a unique Mac feature issue?

1 Like

JPKM20402
Observer
Observer

I was having the same issue and it has been very frustrating.  The simple defined solution also worked for me within OSX.

0 Likes

riik_b
Participant
Participant

hey,

 

i had the same problems and i reloaded adsk.core and adsk.fusion after which it ran as it should, this was on windows. So thanks for the tip

0 Likes

vonbinderhosen
Observer
Observer

Can I re-open this topic? My code was working fine until I decomposed it into a set of modules to make it much cleaner. I.e. it was originally all in one giant python file. When I broke it out into a nicely organized python module (I'm running on Windows), Fusion 360 will no longer re-load the files without me exiting and re-launching Fusion. It's a nightmare. The trick above did not work, and I tried deleting the modules on load, but it causes other problems.

 

Any other ideas on Windows?

0 Likes

FWIW, that reload trick above, did start working. I didn't realize exactly how to phrase it in my case. I had to manually import each of my custom files from my module and reload each one... what a pain. But does work. Just don't forget to list every single file.

0 Likes