Can PythonStartup path be set with .mod modules?

Can PythonStartup path be set with .mod modules?

FirespriteNate
Advocate Advocate
257 Views
2 Replies
Message 1 of 3

Can PythonStartup path be set with .mod modules?

FirespriteNate
Advocate
Advocate

We need to set a custom PythonStartup path that is on our project work drives under P4 control. At the moment I am setting it (along with other stuff) using a launch script, something like this:

motionbuilder.exe -verbosePython d:\mobu\start.py

and in start.py is something like:

from pyfbsdk import *
config = FBConfigFile("@Application.txt")
config.Set("Python", "PythonStartup", "d:\\mobu\\start_dir", "Set by start.py")

This is grossly oversimplified for clarity, but is there any way to ditch all this and just set this custom PythonStartup path from within a .mod file?

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

Ndgt
Enthusiast
Enthusiast
Accepted solution

Hi, @FirespriteNate 

 

Though module description files (.mod) will not modify PythonStartup, it is possible to specify some custom path for MotionBuilder to look into at startup.

For example, put this .mod file in the directory as the Developer Help describes.

+ CustomPythonStartup 0.1 C:/Mobu_Python/Forum/CustomPythonStartup
python: startup_scripts
python_sys_path: path_for_syspath

Ndgt_1-1762587931043.png

 

This is the result output of startup.

Ndgt_2-1762588060674.png

 

Of course, we can specify the module path as startup path directly.

+ CustomPythonStartup 0.1 C:/Mobu_Python/Forum/CustomPythonStartup
python: .

 

With this .mod file, the scripts under the CustomPythonStartup will be executed at startup.

 

Hope this helps.

 

Best Regards,

Ndgt

Message 3 of 3

FirespriteNate
Advocate
Advocate

Many thanks, that seems to work!

I started setting this up on MoBu 2022 which has no modules, hence the rather convoluted PythonStartup approach, but this is much better.

I knew I could add paths to a module, but I didn't realise adding a path to "python" would auto-run the files within it!