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:
authorMartin Poirier <theeth@yahoo.com>2008-05-28 00:02:38 +0400
committerMartin Poirier <theeth@yahoo.com>2008-05-28 00:02:38 +0400
commitc1874b3cee1fdb2220f26f75e676942aee4be561 (patch)
tree88813f1f580d8c5484c00ee480917ee5c7323939 /source/blender/python
parent83a7fbf499ee51051f66bfa5fe23caa96cb262b7 (diff)
[#10223] a new object function to add vertex group from an armature
Patch from Jean-Michel Soler (with slight modifs) Small BPy feature to help script writers deal with armatures and vertex groups (calls the bone heat method to create and assign groups)
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Object.c39
-rw-r--r--source/blender/python/api2_2x/doc/Object.py7
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 82f99adcdb1..1a806932bdb 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -341,6 +341,7 @@ static int setupPI(Object* ob);
static PyObject *Object_getParticleSys( BPy_Object * self );
/* fixme Object_newParticleSys( self, default-partsys-name ) */
+static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args);
static PyObject *Object_newParticleSys( BPy_Object * self );
static PyObject *Object_buildParts( BPy_Object * self );
static PyObject *Object_clearIpo( BPy_Object * self );
@@ -475,6 +476,8 @@ static PyMethodDef BPy_Object_methods[] = {
"Return a list of particle systems"},
{"newParticleSystem", ( PyCFunction ) Object_newParticleSys, METH_NOARGS,
"Create and link a new particle system"},
+ {"addVertexGroupsFromArmature" , ( PyCFunction ) Object_addVertexGroupsFromArmature, METH_VARARGS,
+ "Add vertex groups from armature using the bone heat method"},
{"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
"Recalcs particle system (if any), (depricated, will always return an empty list in version 2.46)"},
{"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
@@ -1109,6 +1112,42 @@ PyObject *Object_newParticleSys( BPy_Object * self ){
return ParticleSys_CreatePyObject(rpsys,ob);
}
+/*****************************************************************************/
+/* attribute: addVertexGroupsFromArmature */
+/* Description: evaluate and add vertex groups to the current object */
+/* for each bone of the selected armature */
+/* Data: self Object, Bpy armature */
+/* Return: nothing */
+/*****************************************************************************/
+static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args)
+{
+
+ Object *ob = self->object;
+ BPy_Object *arm;
+
+ if( ob->type != OB_MESH )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Only useable on Mesh type Objects" );
+
+ if( G.obedit != NULL)
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "Not useable when inside edit mode" );
+
+ /* Check if the arguments passed to makeParent are valid. */
+ if( !PyArg_ParseTuple( args, "O!",&Object_Type, &arm ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "An armature object is expected." );
+
+ if( arm->object->type != OB_ARMATURE )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "An armature object is expected." );
+
+ add_verts_to_dgroups(ob, arm->object, 1, 0);
+ ob->recalc |= OB_RECALC_OB;
+
+ Py_RETURN_NONE;
+}
+
static PyObject *Object_buildParts( BPy_Object * self )
{
/* This is now handles by modifiers */
diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py
index 521be3b0cea..09167c0e117 100644
--- a/source/blender/python/api2_2x/doc/Object.py
+++ b/source/blender/python/api2_2x/doc/Object.py
@@ -651,6 +651,13 @@ class Object:
Link a new particle system (see Blender.Particle).
"""
+ def addVertexGroupsFromArmature(object):
+ """
+ Add vertex groups from armature using the bone heat method
+ This method can be only used with an Object of the type Mesh when NOT in edit mode.
+ @type object: a bpy armature
+ """
+
def buildParts():
"""
Recomputes the particle system. This method only applies to an Object of