On Aug 31, 3:33 pm, fernando <[EMAIL PROTECTED]> wrote: > Thanks for the responses. To be more specific, this code is part of a > Maya plugin. The funcion MFnPlugin::registerUI takes a pointer to a > PyObject which is the function that will set up the UI for that > plugin. The code Matimus posted seems to me exactly like what I need > to do, except that maya gives me an error when I call > PyImport_ImportModule... I don't even have a chance to check the > return value, Maya simply gives up. I have checked that python is > initialized by the time I call this function, and the python path is > correct, I can load the module from the maya python interpreter. What > bugs me is that PyImport_ImportModule doesn't even return, it should > return 0 if something bad happened, right? > > Here's my code: > > if(Py_IsInitialized()) > cout << "python is already initialized" << endl; > if(!Py_IsInitialized()){ > cout << "had do initialize python" << endl; > Py_Initialize();} > > PyObject* mod= PyImport_ImportModule("vzPyTest"); > if(mod == 0){ > cout << "didn't load" << endl;} > > PyObject* func1 = PyObject_GetAttrString(mod, "vzPyTest.test1"); > PyObject* func2 = PyObject_GetAttrString(mod, "vzPyTest.test2"); > plugin.registerUI(func1, func2); > > Thanks for the help!!! One thing I've learned is that the C interface can be tricky the first time.
Is Maya a different python build than what is contained at python.org? If so, I suggest you get your C program to work with the latest python build from python.org. Then see if you can get it to work with the Maya version. -- http://mail.python.org/mailman/listinfo/python-list