Re: Registering a python function in C



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!!!

.



Relevant Pages

  • Re: ANN: 3Delight 5.0 (Moroder)
    ... The package now comes with a Maya plugin ... workflow and a RenderMan MEL binding. ... I am posting this message to have some help with the Maya plugin. ... The plugin won't load. ...
    (comp.graphics.rendering.renderman)
  • Re: Registering a python function in C
    ... Maya plugin. ... The code Matimus posted seems to me exactly like what I need ... I have checked that python is ...
    (comp.lang.python)
  • Python Interactive Interpreter Breakage
    ... I am trying to write a Python module to embed the functionality of ... Maya (the 3D modelling and animation application from Autodesk, ... processes in Python. ... An input script for this would be something like: ...
    (comp.lang.python)
  • ANN: Python cgkit v2.0.0alpha7 & Maya/Python 0.9.3
    ... The Python Computer Graphics Kit is an Open Source software package ... into Maya, and the accompanying Python package "maya" that makes Maya ... functionality available in Python. ...
    (comp.graphics.rendering.renderman)
  • ANN: Python cgkit v2.0.0alpha7 & Maya/Python 0.9.3
    ... The Python Computer Graphics Kit is an Open Source software package ... into Maya, and the accompanying Python package "maya" that makes Maya ... The newly wrapped classes mainly consist of the ...
    (comp.lang.python.announce)