[Bf-python] NMesh module and vertex groups
models at paposo.com
models at paposo.com
Sun Nov 16 01:01:49 CET 2003
> > About the new vgrouping methods: sure, those are necessary additions.
> > That's your area ; ), will you implement them, Joseph?
How about this: (for checking :)
I noticed that vgroup names must be no longer than 32 chars so I also add
this check to addVertGroup()
static PyObject *NMesh_renameVertGroup (PyObject *self, PyObject *args)
{
char * oldGr;
char * newGr;
bDeformGroup * defGroup;
if (!PyArg_ParseTuple(args, "ss", &oldGr, &newGr))
return EXPP_ReturnPyObjError (PyExc_TypeError,
"Expected string & string argument");
defGroup = NULL;
if(!((BPy_NMesh*)self)->object)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"This mesh must be linked to an object");
if (strlen(newGr) > 32 || strlen(newGr) < 1)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"Group names must be between 1 and 32 characters");
defGroup = get_named_vertexgroup(((BPy_NMesh*)self)->object, oldGr);
if(defGroup == NULL)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"Couldn't find the expected vertex group");
strcpy (defGroup->name, newGr);
unique_vertexgroup_name(defGroup, ((BPy_NMesh*)self)->object);
return EXPP_incr_ret (Py_None);
}
static PyObject *NMesh_getVertGroupNames (PyObject *self, PyObject *args)
{
bDeformGroup * defGroup;
PyObject *list;
if(!((BPy_NMesh*)self)->object)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"This mesh must be linked to an object");
list = PyList_New(0);
for (defGroup = (((BPy_NMesh*)self)->object)->defbase.first; defGroup;
defGroup=defGroup->next){
if(PyList_Append(list,PyString_FromString(defGroup->name)) < 0)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"Couldn't add item to list");
}
return list;
}
More information about the Bf-python
mailing list