- added vgrouping methods for renaming a vertex group and returning all vgroup names

This commit is contained in:
Joseph Gilbert 2003-11-17 07:13:27 +00:00
parent b43e74a1db
commit 33da577d34

@ -1066,6 +1066,8 @@ static struct PyMethodDef NMesh_methods[] =
MethodDef(assignVertsToGroup), MethodDef(assignVertsToGroup),
MethodDef(removeVertsFromGroup), MethodDef(removeVertsFromGroup),
MethodDef(getVertsFromGroup), MethodDef(getVertsFromGroup),
MethodDef(renameVertGroup),
MethodDef(getVertGroupNames),
MethodDef(hasVertexColours), MethodDef(hasVertexColours),
MethodDef(hasFaceUV), MethodDef(hasFaceUV),
MethodDef(hasVertexUV), MethodDef(hasVertexUV),
@ -2214,6 +2216,7 @@ static PyObject *NMesh_addVertGroup (PyObject *self, PyObject *args)
{ {
char* groupStr; char* groupStr;
struct Object* object; struct Object* object;
PyObject *tempStr;
if (!PyArg_ParseTuple(args, "s", &groupStr)) if (!PyArg_ParseTuple(args, "s", &groupStr))
return EXPP_ReturnPyObjError (PyExc_TypeError, return EXPP_ReturnPyObjError (PyExc_TypeError,
@ -2225,6 +2228,10 @@ static PyObject *NMesh_addVertGroup (PyObject *self, PyObject *args)
object = ((BPy_NMesh*)self)->object; object = ((BPy_NMesh*)self)->object;
//get clamped name
tempStr = PyString_FromStringAndSize(groupStr, 32);
groupStr = PyString_AsString(tempStr);
add_defgroup_name (object, groupStr); add_defgroup_name (object, groupStr);
allqueue (REDRAWBUTSALL, 1); allqueue (REDRAWBUTSALL, 1);
@ -2567,3 +2574,52 @@ static PyObject *NMesh_getVertsFromGroup (PyObject *self, PyObject *args)
return (vertexList); return (vertexList);
} }
static PyObject *NMesh_renameVertGroup (PyObject *self, PyObject *args)
{
char * oldGr = NULL;
char * newGr = NULL;
bDeformGroup * defGroup = NULL;
PyObject *tempStr;
if(!((BPy_NMesh*)self)->object)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"This mesh must be linked to an object");
if (!PyArg_ParseTuple(args, "ss", &oldGr, &newGr))
return EXPP_ReturnPyObjError (PyExc_TypeError,
"Expected string & string argument");
defGroup = get_named_vertexgroup(((BPy_NMesh*)self)->object, oldGr);
if(defGroup == NULL)
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
"Couldn't find the expected vertex group");
//set name
tempStr = PyString_FromStringAndSize(newGr, 32);
newGr = PyString_AsString(tempStr);
memcpy (defGroup->name, newGr, 32);
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;
}