Friday, April 18, 2008

Weird Maya Python plug-in behavior

I found a weird Maya Python plug-in behavior yesterday.

When I make a plug-in like this,

class ClassD(object):

def initializePlugin(mobject):
print ClassD.__module__

def uninitializePlugin(mobject):

and load it, it prints out


How come a method is defined in the built in module?
It means you cannot use global declaration.
You need to either import the plug-in module inside the code like,

import pyCommandPort
pyCommandPort.someattribute = somevalue

or need to separate the code from the plug-in file and import it.

The globals() returns the right dictionary, and the class is not
in the builtin module. Looks Maya is doing some complicated things.

No comments: