You can have your class in a location that is in your system or python
path. I have a directory on my C drive that has a bunch of packages I've
downloaded that I've added to my Windows 'Python_Path' variable in the
Computers Environment variables location. This makes it accessible from any
python interpreter on my machine (Softimage, Maya, IDLE).

Another way to do it without having to change your system or python path
variables is to add it to the system path dynamically when you load the
plugin. You can take a look at the code for many (if not all) of my plugins
on my github page (https://github.com/EricTRocks/ET_Tools) for how you can
go about that. The downside to that is that you have to know the full path
or be able to derive that somewhere to the location of the class file.

Sounds like you're deploying it studio wide which makes me wonder if there
is a mechanism currently in place that allows you to distribute your shared
libraries easily so that the libraries are synced from a server to each
machine so you can use the same location on each workstation there.

Long and the short of it, you just need to have the directory where the
MyClass.py file lives added to a system or python path variable in one way
or another.

--------------------------------------------
Eric Thivierge
http://www.ethivierge.com


On Mon, Feb 4, 2013 at 12:47 PM, Christian Gotzinger
<[email protected]>wrote:

> Hi list,
>
> I want to write a class and put it in a separate .py file. This is so we
> can use it in both Softimage and Maya. I then want to write a script that
> makes use of the class.
> Question: what is the proper way of doing this, i.e. where do I store the
> external file so that a script can import and use it?
>
> Thank you
>
> Christian
>

Reply via email to