Updating imported Python scripts

Updating imported Python scripts

Anonymous
Not applicable
1,918 Views
2 Replies
Message 1 of 3

Updating imported Python scripts

Anonymous
Not applicable

Hi,

I've been having some issues with imported Python Scripts on Motionbuilder.

I have a small module that I created, but I did not want to leave it at

C:\Program Files\Autodesk\MotionBuilder 2015\bin\x64\python\lib

where MotionBuilder will look for scripts.

 

I am leaving them in another folder. For this reason I am importing my other folder into the Path variable, such as follows

 

from pyfbsdk import *
import json
import os, sys

#Expand path, and import module
lib_folder = os.path.expanduser('~User321\\Drive\\scripts')
if sys.path[-1] != lib_folder:
    sys.path.append(lib_folder)
import serialize_helper

I am assuming the folder would be at the last position of my sys.path.

 

This solution works. The problem happens when I want to make some modifications to the file "serialize_helper.py". Motionbuilder won't reload the updated script, unless I close the whole program, and try restarting it. Does anybody have a suggestion. Am I doing it wrong? Is there a proper way of loading modules?

 

0 Likes
Accepted solutions (1)
1,919 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Hi,

 

You need to reload your module to force mobu to update it. Add this to your code:

 

import serialize_helper
reload(serialize_helper)

 

Cheers

Message 3 of 3

Anonymous
Not applicable

Thanks a lot

0 Likes