Re: Registering a python function in C
- From: "AnonMail2005@xxxxxxxxx" <AnonMail2005@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 13:27:27 -0700
On Aug 31, 3:33 pm, fernando <fernandofariajun...@xxxxxxxxx> wrote:
Thanks for the responses. To be more specific, this code is part of aOne thing I've learned is that the C interface can be tricky the first
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!!!
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.
.
- References:
- Registering a python function in C
- From: fernando
- Re: Registering a python function in C
- From: Matimus
- Re: Registering a python function in C
- From: fernando
- Registering a python function in C
- Prev by Date: Re: status of Programming by Contract (PEP 316)?
- Next by Date: Re: Biased random?
- Previous by thread: Re: Registering a python function in C
- Next by thread: Re: Registering a python function in C
- Index(es):
Relevant Pages
|