[Bf-committers] python callbacks
bf-committers@blender.org
bf-committers@blender.org
Tue, 6 Jan 2004 00:12:34 +0000
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
hello,
attached is my patch which adds some python call back code. it will store a python function with Blender.CallbackFrameChange(myfunc) and run that func everytime the frame changes. i shall be looking to implement more functions like thia.
this is my first patch so please be critical so i may do better next time ;)
i am also working on a render module that allows python to start the render process but this i shall look at again before submitting anything.
have fun
dunk ( d1223m on irc, hello #blendercoders )
------------------------------------------------
http://30bentham.homelinux.org
http://www.dunkfordyce.co.uk
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="callbackdiff.txt"
? Makefile.in
? diff.txt
? api2_2x/Makefile.in
Index: BPY_extern.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/BPY_extern.h,v
retrieving revision 1.8
diff -r1.8 BPY_extern.h
75a76,79
>
> /* for python callbacks */
> extern *bpy_callbackFrameChange;
> void BPY_callbackFrameChange();
Index: BPY_interface.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/BPY_interface.c,v
retrieving revision 1.26
diff -r1.26 BPY_interface.c
557a558,559
> BPY_callbackFrameChange();
>
829a832,833
>
>
Index: api2_2x/Blender.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Blender.c,v
retrieving revision 1.26
diff -r1.26 Blender.c
233a234,274
>
> static PyObject *Blender_callbackFrameChange(PyObject *dummy, PyObject *args)
> {
> PyObject *result=NULL;
> PyObject *temp;
>
> printf("my_set_callback");
>
> if (PyArg_ParseTuple(args, "O:set_callback", &temp)) {
> if (!PyCallable_Check(temp)) {
> PyErr_SetString(PyExc_TypeError, "parameter must be callable");
> return NULL;
> }
>
> Py_XINCREF(temp);
> Py_XDECREF(bpy_callbackFrameChange);
> bpy_callbackFrameChange=temp;
> Py_INCREF(Py_None);
> result=Py_None;
> }
> return result;
> }
>
> /*****************************************************************************/
> /* Description: checks to see if the user call back variable has a */
> /* contains a callable function and then calls it */
> /*****************************************************************************/
> void BPY_callbackFrameChange()
> {
> PyObject *arglist;
> PyObject *result;
>
> if (!PyCallable_Check(bpy_callbackFrameChange)) {
> return;
> }
>
> arglist=Py_BuildValue("()");
> result=PyEval_CallObject(bpy_callbackFrameChange,arglist);
>
> Py_DECREF(arglist);
> }
Index: api2_2x/Blender.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Blender.h,v
retrieving revision 1.4
diff -r1.4 Blender.h
52a53,54
> PyObject *bpy_callbackFrameChange=NULL;
>
64a67
> PyObject *Blender_callbackFrameChange(PyObject *self, PyObject *args);
104a108
> {"CallbackFrameChange", &Blender_callbackFrameChange, METH_VARARGS, ""},
--6c2NcOVqGQ03X4Wi--