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:
authorNathan Letwory <nathan@letworyinteractive.com>2008-10-20 03:20:17 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2008-10-20 03:20:17 +0400
commit036c4f643441f3302cabc0f83eca3f2cd157cf10 (patch)
tree2cb757992cbcdb895162e981158d2508c53f42a2 /source/blender/python
parentae9953bb873c59d6566f2335be058e3f733b8036 (diff)
=== Blender Python API ===
* add DataSize() to module level with this one can get datablock struct size.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Armature.c27
-rw-r--r--source/blender/python/api2_2x/Material.c9
-rw-r--r--source/blender/python/api2_2x/Mesh.c31
-rw-r--r--source/blender/python/api2_2x/Object.c20
4 files changed, 80 insertions, 7 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index acf18ac6058..dab2d49df0c 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -923,7 +923,7 @@ AttributeError:
sArmatureError, "You are not allowed to change the .Bones attribute");
}
-//------------------------Bone.layerMask (get)
+//------------------------Armature.layerMask (get)
static PyObject *Armature_getLayerMask(BPy_Armature *self)
{
/* do this extra stuff because the short's bits can be negative values */
@@ -931,7 +931,7 @@ static PyObject *Armature_getLayerMask(BPy_Armature *self)
laymask |= self->armature->layer;
return PyInt_FromLong((int)laymask);
}
-//------------------------Bone.layerMask (set)
+//------------------------Armature.layerMask (set)
static int Armature_setLayerMask(BPy_Armature *self, PyObject *value)
{
int laymask;
@@ -1295,6 +1295,26 @@ static PyObject *M_Armature_New(PyObject * self, PyObject * args)
return (PyObject *)obj;
}
+static PyObject *M_Armature_DataSize(PyObject * self, PyObject *args)
+{
+ int t = 0;
+ int ret = 0;
+ if( !PyArg_ParseTuple(args, "|i", &t))
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int as argument" );
+
+ switch(t) {
+ case 0:
+ ret = sizeof(struct bArmature);
+ break;
+ default:
+ ret = sizeof(struct Bone);
+ break;
+ }
+
+ return PyInt_FromLong(ret);
+}
+
//-------------------MODULE METHODS DEFINITION-----------------------------
@@ -1304,9 +1324,12 @@ static char M_Armature_Get_doc[] = "(name) - return the armature with the name '
static char M_Armature_New_doc[] = "(name) - return a new armature object.";
+static char M_Armature_DataSize_doc[] = "(type) - return sizeof of either Armature (0) or Bone (1).";
+
struct PyMethodDef M_Armature_methods[] = {
{"Get", M_Armature_Get, METH_VARARGS, M_Armature_Get_doc},
{"New", M_Armature_New, METH_VARARGS, M_Armature_New_doc},
+ {"DataSize", M_Armature_DataSize, METH_VARARGS, M_Armature_DataSize_doc},
{NULL, NULL, 0, NULL}
};
//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 2e6bd326fb6..02fdc32c5c9 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -207,6 +207,7 @@
static PyObject *M_Material_New( PyObject * self, PyObject * args,
PyObject * keywords );
static PyObject *M_Material_Get( PyObject * self, PyObject * args );
+static PyObject *M_Material_DataSize(PyObject *unused);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. In */
@@ -231,6 +232,8 @@ struct PyMethodDef M_Material_methods[] = {
M_Material_New_doc},
{"Get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
{"get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
+ {"DataSize", ( PyCFunction ) M_Material_DataSize, METH_NOARGS,
+ "Get sizeof() of Material"},
{NULL, NULL, 0, NULL}
};
@@ -335,6 +338,12 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
}
}
+static PyObject *M_Material_DataSize(PyObject *unused)
+{
+ return PyInt_FromLong(sizeof(Material));
+}
+
+
static PyObject *Material_ModesDict( void )
{
PyObject *Modes = PyConstant_New( );
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index d513a8be4db..fdecd66f5e2 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -8637,6 +8637,35 @@ static PyObject *M_Mesh_MVert( PyObject * self_unused, PyObject * args )
return PVert_CreatePyObject( &vert );
}
+static PyObject *M_Mesh_DataSize(PyObject * self, PyObject *args)
+{
+ int t = 0;
+ int ret = 0;
+ if( !PyArg_ParseTuple(args, "|i", &t))
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected nothing or an int as argument" );
+
+ switch(t) {
+ case 0:
+ ret = sizeof(Mesh);
+ break;
+ case 1:
+ ret = sizeof(MVert);
+ break;
+ case 2:
+ ret = sizeof(MEdge);
+ break;
+ case 3:
+ ret = sizeof(MFace);
+ break;
+ default:
+ ret = sizeof(Mesh);
+ break;
+ }
+
+ return PyInt_FromLong(ret);
+}
+
static PyObject *M_Mesh_Modes( PyObject * self_unused, PyObject * args )
{
int modes = 0;
@@ -8668,6 +8697,8 @@ static struct PyMethodDef M_Mesh_methods[] = {
"Create a new MVert"},
{"Mode", (PyCFunction)M_Mesh_Modes, METH_VARARGS,
"Get/set edit selection mode(s)"},
+ {"DataSize", (PyCFunction)M_Mesh_DataSize, METH_VARARGS,
+ "Get sizeof() of Mesh (0), MVert (1), MEdge (2) or MFace (3)"},
{NULL, NULL, 0, NULL},
};
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index a6ee9b7d540..f14ac81fe24 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -290,6 +290,7 @@ static PyObject *M_Object_New( PyObject * self, PyObject * args );
PyObject *M_Object_Get( PyObject * self, PyObject * args );
static PyObject *M_Object_GetSelected( PyObject * self );
static PyObject *M_Object_Duplicate( PyObject * self, PyObject * args, PyObject *kwd);
+static PyObject *M_Object_DataSize( PyObject * self );
/* HELPER FUNCTION FOR PARENTING */
static PyObject *internal_makeParent(Object *parent, PyObject *py_child, int partype, int noninverse, int fast, int v1, int v2, int v3, char *bonename);
@@ -299,25 +300,27 @@ static PyObject *internal_makeParent(Object *parent, PyObject *py_child, int par
/* In Python these will be written to the console when doing a */
/* Blender.Object.__doc__ */
/*****************************************************************************/
-char M_Object_doc[] = "The Blender Object module\n\n\
+static char M_Object_doc[] = "The Blender Object module\n\n\
This module provides access to **Object Data** in Blender.\n";
-char M_Object_New_doc[] =
+static char M_Object_New_doc[] =
"(type) - Add a new object of type 'type' in the current scene";
-char M_Object_Get_doc[] =
+static char M_Object_Get_doc[] =
"(name) - return the object with the name 'name', returns None if not\
found.\n\
If 'name' is not specified, it returns a list of all objects in the\n\
current scene.";
-char M_Object_GetSelected_doc[] =
+static char M_Object_GetSelected_doc[] =
"() - Returns a list of selected Objects in the active layer(s)\n\
The active object is the first in the list, if visible";
-char M_Object_Duplicate_doc[] =
+static char M_Object_Duplicate_doc[] =
"(linked) - Duplicate all selected, visible objects in the current scene";
+static char M_Object_DataSize_doc[] =
+ "() - return the sizeof(Object)";
/*****************************************************************************/
/* Python method structure definition for Blender.Object module: */
@@ -331,6 +334,8 @@ struct PyMethodDef M_Object_methods[] = {
M_Object_GetSelected_doc},
{"Duplicate", ( PyCFunction ) M_Object_Duplicate, METH_VARARGS | METH_KEYWORDS,
M_Object_Duplicate_doc},
+ {"DataSize", ( PyCFunction ) M_Object_DataSize, METH_NOARGS,
+ M_Object_DataSize_doc},
{NULL, NULL, 0, NULL}
};
@@ -1037,6 +1042,11 @@ static PyObject *M_Object_Duplicate( PyObject * self_unused,
Py_RETURN_NONE;
}
+static PyObject *M_Object_DataSize(PyObject * self)
+{
+ return PyInt_FromLong(sizeof(Object));
+}
+
/*****************************************************************************/
/* Python BPy_Object methods: */