Python Modules like XSI Plugins
This great post told me how to set properly the pythonpath when XSI start . It works fine . I could import my modules and work with them .
But how could I make it work with other plugins ?
I make some plugins importing some modules I built in workgroup folder , every time I start XSI , they failed to find modules , and after I open their scripts , re-save without changing the code , it works again .
That means those plugins are loaded before this event . So python module paths haven’t been added when loading those plugins .
Is there anyway to do the trick ? I mean make it work without force other team members execute any scripts or doing anything else , but only connect to the workgroup.
Such as way to changge plugin oreder , or to make plugins being loaded after certain events by declaration in their codes .
How to make my python modules work with my python plugins ?
-
antonieo
- Posts: 7
- Joined: 13 Apr 2011, 03:37
-
EricTRocks
- Moderator
- Posts: 754
- Joined: 25 Nov 2009, 00:41
Re: How to make my python modules work with my python plugins ?
Load order is essential for plugins that add the module paths to the system path. I have only been using modules in plugins that aren't events so I'm not sure exactly a great workaround. The only thing I could think of is to name your plugin something that will load it first so something like aLoadModules.py. It's very hacky but will most likely work.
Either that or just have a function in your event plugin that registers the modules before loading and running the event.
Either that or just have a function in your event plugin that registers the modules before loading and running the event.
-
antonieo
- Posts: 7
- Joined: 13 Apr 2011, 03:37
Re: How to make my python modules work with my python plugins ?
It works as you say , I renamed the add_python_path.py plugin file start with character "a" , and I move the < add python path code > to the global initializing phase , to make sure the paths will be added at the very beginning of plugin loading phase .
Cause the add_python_path plugin will be load before others , paths of modules will be added at that moment . Then other plugins are loaded later , they can import my modules directly !!!
Nice !!!
Thx !!!
Cause the add_python_path plugin will be load before others , paths of modules will be added at that moment . Then other plugins are loaded later , they can import my modules directly !!!
Nice !!!
Thx !!!