diff options
author | Tom Musgrove <LetterRip@gmail.com> | 2008-02-03 02:58:05 +0300 |
---|---|---|
committer | Tom Musgrove <LetterRip@gmail.com> | 2008-02-03 02:58:05 +0300 |
commit | 07ccea0ac22f40f15832f71b1b948ca9927b3333 (patch) | |
tree | 95ea69a122a50ba0f76f8c12fe867e65663bab6e /source/blender/python | |
parent | 3a6a3d0389d6e2cee0f91e721667853ba7fdafc3 (diff) |
== Python API - Mesh ==
This patch by Domino Maram adds the function addMultiresLevel
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 33 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Mesh.py | 9 |
2 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 69975ed611e..803c0b96ef3 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -7178,6 +7178,36 @@ static int Mesh_setMultires( BPy_Mesh * self, PyObject *value, void *type ) return 0; } +static PyObject *Mesh_addMultiresLevel( BPy_Mesh * self, PyObject * args ) +{ + char typenum; + int i, levels = 1; + char *type = NULL; + if( G.obedit ) + return EXPP_ReturnPyObjError(PyExc_RuntimeError, + "can't add multires level while in edit mode" ); + if( !PyArg_ParseTuple( args, "|is", &levels, &type ) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected nothing or an int and optionally a string as arguments" ); + if( !type || !strcmp( type, "catmull-clark" ) ) + typenum = 0; + else if( !strcmp( type, "simple" ) ) + typenum = 1; + else + return EXPP_ReturnPyObjError( PyExc_AttributeError, + "if given, type should be 'catmull-clark' or 'simple'" ); + if (!self->mesh->mr) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "the mesh has no multires data" ); + for( i = 0; i < levels; i++ ) { + multires_add_level(self->object, self->mesh, typenum); + }; + multires_update_levels(self->mesh, 0); + multires_level_to_editmesh(self->object, self->mesh, 0); + multires_finish_mesh_update(self->object); + Py_RETURN_NONE; +} + /* end multires */ @@ -7559,6 +7589,9 @@ static struct PyMethodDef BPy_Mesh_methods[] = { "Rename a UV Layer"}, {"renameColorLayer", (PyCFunction)Mesh_renameColorLayer, METH_VARARGS, "Rename a Color Layer"}, + /* mesh multires */ + {"addMultiresLevel", (PyCFunction)Mesh_addMultiresLevel, METH_VARARGS, + "(levels=1, type='catmull-clark') - adds multires levels of given type"}, /* python standard class functions */ {"__copy__", (PyCFunction)Mesh_copy, METH_NOARGS, diff --git a/source/blender/python/api2_2x/doc/Mesh.py b/source/blender/python/api2_2x/doc/Mesh.py index 7e7514e8b3a..0690b94712b 100644 --- a/source/blender/python/api2_2x/doc/Mesh.py +++ b/source/blender/python/api2_2x/doc/Mesh.py @@ -1102,6 +1102,15 @@ class Mesh: @param name: The name of the new Color layer, 31 characters max. """ + def addMultiresLevel(levels = 1, type = 'catmull-clark'): + """ + Adds multires levels to this mesh. + @type levels: int + @param levels: The number of levels to add + @type type: string + @param type: The type of multires level, 'catmull-clark' or 'simple'. + """ + def removeUVLayer(name): """ Removes the active UV/Image layer. |