Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Alatalo <antont@kyperjokki.fi>2006-02-08 19:58:12 +0300
committerToni Alatalo <antont@kyperjokki.fi>2006-02-08 19:58:12 +0300
commita3d0d456ac84279beffb08da2056a718448639a2 (patch)
tree407f32cfdca184c9ec3e47f9fed9de00d6315e51 /source/blender/python/api2_2x/Blender.c
parent839b338be35dd11d30231d1dee1a3454b952ab55 (diff)
More things for easying the job of replacing proxy/working armatures in the scenes of Elephants Dream with the final ones: 1) adds removing Fakeusers from Actions to PyAPI, now with a hackish call in the Blender module. Possibility of better ways should be discussed on bf-python. 2) adds BPY Object.copyNLA(otherob) - that was simple 'cause the copy_nla function was nicely in kernel nla.c. 3) Object.convertActionToStrip(), here it gets tricky: the function to convert the active action of an object to a NLA strip was buried inside the respective function in the GUI editnla.c which had also code for reading mouse coordinates and whatnot. So I took the actual copying out of it and moved it to the kernel nla.c as a new function, bActionStrip *convert_action_to_strip (Object *ob). that code used other functions, of which find_stridechannel() was also in editnla.c but free of UI code so i moved it to kernel too. kept things with UI code in editnla.c. tried to be careful with keeping mallocs and the pointer business intact, and tested that this works and after usage Blender gives no memory warnings or anything, so seems ok - but certainly is best reviewed by ppl more active with c coding than me. hopefully this little refactor makes it possible to add this function to the menus too, which was not straightforward earlier when Matt took a look at it.
Diffstat (limited to 'source/blender/python/api2_2x/Blender.c')
-rw-r--r--source/blender/python/api2_2x/Blender.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 1bbb91fac7f..f91a6604683 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -85,7 +85,9 @@ struct ID; /*keep me up here */
#include "Window.h"
#include "World.h"
-
+//for the removefakeuser hack
+#include "NLA.h" /*This must come first*/
+#include "BKE_action.h"
extern PyObject *bpy_registryDict; /* defined in ../BPY_interface.c */
@@ -100,6 +102,7 @@ static PyObject *Blender_Quit( PyObject * self );
static PyObject *Blender_Load( PyObject * self, PyObject * args );
static PyObject *Blender_Save( PyObject * self, PyObject * args );
static PyObject *Blender_Run( PyObject * self, PyObject * args );
+static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args);
static PyObject *Blender_ShowHelp( PyObject * self, PyObject * args );
static PyObject *Blender_UpdateMenus( PyObject * self);
@@ -162,6 +165,10 @@ static char Blender_Run_doc[] =
"(script) - Run the given Python script.\n\
(script) - the path to a file or the name of an available Blender Text.";
+static char Blender_RemoveFakeuser_doc[] =
+ "(datablock) - remove the fake user from a datablock. useful for deleting actions.\n\
+(datablock) - the datablock that has a fakeuser. currently only action object accepted.";
+
static char Blender_ShowHelp_doc[] =
"(script) - Show help for the given Python script.\n\
This will try to open the 'Scripts Help Browser' script, so to have\n\
@@ -186,6 +193,7 @@ static struct PyMethodDef Blender_methods[] = {
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
{"Run", Blender_Run, METH_VARARGS, Blender_Run_doc},
+ {"RemoveFakeuser", Blender_RemoveFakeuser, METH_VARARGS, Blender_RemoveFakeuser_doc},
{"ShowHelp", Blender_ShowHelp, METH_VARARGS, Blender_ShowHelp_doc},
{"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
Blender_UpdateMenus_doc},
@@ -764,6 +772,35 @@ static PyObject * Blender_UpdateMenus( PyObject * self )
return Py_None;
}
+static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args)
+{
+ ID *id;
+ BPy_Action *py_thing; //lousy coder antont did not know how to accept any bpy thing with ID..
+
+ if( !PyArg_ParseTuple( args, "O!", &Action_Type, &py_thing ) )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected python action type" );
+
+ id= (ID *)py_thing->action;
+
+ if(id) {
+ if( id->flag & LIB_FAKEUSER) {
+ id->flag -= LIB_FAKEUSER;
+ id->us--;
+ }
+ else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "given datablock has no fakeusers");
+ } else
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "given object does not have a Blender ID");
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+
+
/*****************************************************************************/
/* Function: initBlender */
/*****************************************************************************/