From 8a8400ff28249e538d9b20dee7b9300d72a05b99 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Sun, 28 May 2006 00:39:13 +0000 Subject: [PATCH] ===Python API=== Added to Mesh API me.sel and me.hide, which set/clear the selection and hidden values for all verts/edges/faces in a mesh. --- source/blender/python/api2_2x/Mesh.c | 62 +++++++++++++++++++++++ source/blender/python/api2_2x/doc/Mesh.py | 7 ++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index ba383fd4068..35ef8cdb10a 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -6900,6 +6900,60 @@ static int Mesh_setActiveGroup( BPy_Mesh * self, PyObject * arg ) return 0; } +static int Mesh_setSel( BPy_Mesh * self, PyObject * arg ) +{ + int i; + Mesh *me = self->mesh; + MVert *mvert = me->mvert; + MEdge *medge = me->medge; + MFace *mface = me->mface; + + if( PyObject_IsTrue( arg ) ) { + for( i = 0; i < me->totvert; ++mvert, ++i ) + mvert->flag |= SELECT; + for( i = 0; i < me->totedge; ++medge, ++i ) + medge->flag |= SELECT; + for( i = 0; i < me->totface; ++mface, ++i ) + mface->flag |= ME_FACE_SEL; + } else { + for( i = 0; i < me->totvert; ++mvert, ++i ) + mvert->flag &= ~SELECT; + for( i = 0; i < me->totedge; ++medge, ++i ) + medge->flag &= ~SELECT; + for( i = 0; i < me->totface; ++mface, ++i ) + mface->flag &= ~ME_FACE_SEL; + } + + return 0; +} + +static int Mesh_setHide( BPy_Mesh * self, PyObject * arg ) +{ + int i; + Mesh *me = self->mesh; + MVert *mvert = me->mvert; + MEdge *medge = me->medge; + MFace *mface = me->mface; + + if( PyObject_IsTrue( arg ) ) { + for( i = 0; i < me->totvert; ++mvert, ++i ) + mvert->flag |= ME_HIDE; + for( i = 0; i < me->totedge; ++medge, ++i ) + medge->flag |= ME_HIDE; + for( i = 0; i < me->totface; ++mface, ++i ) + mface->flag |= ME_HIDE; + } else { + for( i = 0; i < me->totvert; ++mvert, ++i ) + mvert->flag &= ~ME_HIDE; + for( i = 0; i < me->totedge; ++medge, ++i ) + medge->flag &= ~ME_HIDE; + for( i = 0; i < me->totface; ++mface, ++i ) + mface->flag &= ~ME_HIDE; + } + + return 0; +} + /************************************************************************ * * Python Mesh_Type standard operations @@ -6987,6 +7041,14 @@ static PyGetSetDef BPy_Mesh_getseters[] = { (getter)Mesh_getActiveGroup, (setter)Mesh_setActiveGroup, "Active group for the mesh", NULL}, + {"sel", + (getter)NULL, (setter)Mesh_setSel, + "Select/deselect all verts, edges, faces in the mesh", + NULL}, + {"hide", + (getter)NULL, (setter)Mesh_setHide, + "Hide/unhide all verts, edges, faces in the mesh", + NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; diff --git a/source/blender/python/api2_2x/doc/Mesh.py b/source/blender/python/api2_2x/doc/Mesh.py index 3b6667638d9..e6668003957 100644 --- a/source/blender/python/api2_2x/doc/Mesh.py +++ b/source/blender/python/api2_2x/doc/Mesh.py @@ -651,7 +651,12 @@ class Mesh: the future. @ivar mode: The mesh's mode bitfield. See L{Modes}. @type mode: int - + @ivar sel: Sets selection status for all vertices, edges and faces in the + mesh (write only). + @type mode: boolean + @ivar hide: Sets hidden status for all vertices, edges and faces in the + mesh (write only). + @type hide: boolean @ivar name: The Mesh name. It's common to use this field to store extra data about the mesh (to be exported to another program, for example). @type name: str