BPY api addition material.freeNodes() - use to cleanup apricot files, since there is no way to remove a node tree via the UI, unused materials and duplicate images were hanging around.

buttons_logic - gave the name a but more room then the controller type, better for documentation screenshots.
This commit is contained in:
2008-09-11 01:51:45 +00:00
parent 9d7c56a7f2
commit 2af7083d75
3 changed files with 30 additions and 5 deletions

View File

@@ -649,7 +649,7 @@ static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args );
static PyObject *Material_getColorband( BPy_Material * self, void * type);
int Material_setColorband( BPy_Material * self, PyObject * value, void * type);
static PyObject *Material_copy( BPy_Material * self );
static PyObject *Material_freeNodes( BPy_Material * self );
/*****************************************************************************/
/* Python BPy_Material methods table: */
@@ -887,6 +887,8 @@ static PyMethodDef BPy_Material_methods[] = {
"() - Return a copy of the material."},
{"copy", ( PyCFunction ) Material_copy, METH_NOARGS,
"() - Return a copy of the material."},
{"freeNodes", ( PyCFunction ) Material_freeNodes, METH_NOARGS,
"() - Free this materials nodes."},
{NULL, NULL, 0, NULL}
};
@@ -2588,6 +2590,22 @@ static PyObject *Material_copy( BPy_Material * self )
return ( PyObject * ) pymat;
}
/* mat.freeNodes() */
static PyObject *Material_freeNodes( BPy_Material * self )
{
if (self->material->nodetree) {
if(self->material->nodetree) {
ntreeFreeTree(self->material->nodetree);
MEM_freeN(self->material->nodetree);
}
self->material->nodetree = NULL;
self->material->use_nodes = 0;
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
}
/* mat_a==mat_b or mat_a!=mat_b*/
static int Material_compare( BPy_Material * a, BPy_Material * b )
{

View File

@@ -1087,5 +1087,12 @@ class Material:
@return: a copy of this material
"""
def freeNodes ():
"""
Removes the node tree from this material.
@rtype: bool
@return: true if nodes were freed from this material.
"""
import id_generics
Material.__doc__ += id_generics.attributes