[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16468] trunk/blender/source/blender: 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.
Campbell Barton
ideasman42 at gmail.com
Thu Sep 11 03:51:50 CEST 2008
Revision: 16468
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16468
Author: campbellbarton
Date: 2008-09-11 03:51:45 +0200 (Thu, 11 Sep 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Material.c
trunk/blender/source/blender/python/api2_2x/doc/Material.py
trunk/blender/source/blender/src/buttons_logic.c
Modified: trunk/blender/source/blender/python/api2_2x/Material.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Material.c 2008-09-10 23:22:12 UTC (rev 16467)
+++ trunk/blender/source/blender/python/api2_2x/Material.c 2008-09-11 01:51:45 UTC (rev 16468)
@@ -649,8 +649,8 @@
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 @@
"() - 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 @@
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 )
{
Modified: trunk/blender/source/blender/python/api2_2x/doc/Material.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Material.py 2008-09-10 23:22:12 UTC (rev 16467)
+++ trunk/blender/source/blender/python/api2_2x/doc/Material.py 2008-09-11 01:51:45 UTC (rev 16468)
@@ -1087,5 +1087,12 @@
@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
Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c 2008-09-10 23:22:12 UTC (rev 16467)
+++ trunk/blender/source/blender/src/buttons_logic.c 2008-09-11 01:51:45 UTC (rev 16468)
@@ -3298,8 +3298,8 @@
if(cont->flag & CONT_SHOW) {
cont->otype= cont->type;
- uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 100, 19, &cont->type, 0, 0, 0, 0, "Controller type");
- but= uiDefBut(block, TEX, 1, "", (short)(xco+122), yco, (short)(width-166), 19, cont->name, 0, 31, 0, 0, "Controller name");
+ uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 70, 19, &cont->type, 0, 0, 0, 0, "Controller type");
+ but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-136), 19, cont->name, 0, 31, 0, 0, "Controller name");
uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0);
ycoo= yco;
@@ -3309,9 +3309,9 @@
else {
cpack(0x999999);
glRecti(xco+22, yco, xco+width-22,yco+19);
- but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 100, 19, cont, 0, 0, 0, 0, "Controller type");
+ but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 70, 19, cont, 0, 0, 0, 0, "Controller type");
uiButSetFunc(but, sca_move_controller, cont, NULL);
- but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+122), yco,(short)(width-166), 19, cont, 0, 0, 0, 0, "Controller name");
+ but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+92), yco,(short)(width-136), 19, cont, 0, 0, 0, 0, "Controller name");
uiButSetFunc(but, sca_move_controller, cont, NULL);
ycoo= yco;
}
More information about the Bf-blender-cvs
mailing list