[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52649] trunk/blender/source/blender/ python/bmesh/bmesh_py_types.c: bmesh py api: add BMeshFaceSeq. active attribute- bm.faces.active
Campbell Barton
ideasman42 at gmail.com
Thu Nov 29 03:44:10 CET 2012
Revision: 52649
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52649
Author: campbellbarton
Date: 2012-11-29 02:44:06 +0000 (Thu, 29 Nov 2012)
Log Message:
-----------
bmesh py api: add BMeshFaceSeq.active attribute- bm.faces.active
Modified Paths:
--------------
trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-11-29 02:37:39 UTC (rev 52648)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-11-29 02:44:06 UTC (rev 52649)
@@ -555,6 +555,53 @@
return BPy_BMLayerAccess_CreatePyObject(self->bm, GET_INT_FROM_POINTER(htype));
}
+/* FaceSeq
+ * ^^^^^^^ */
+
+PyDoc_STRVAR(bpy_bmfaceseq_active_doc,
+"active face.\n\n:type: :class:`BMFace` or None"
+);
+static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(closure))
+{
+ BMesh *bm = self->bm;
+ BPY_BM_CHECK_OBJ(self);
+
+ if (bm->act_face) {
+ return BPy_BMElem_CreatePyObject(bm, (BMHeader *)bm->act_face);
+ }
+ else {
+ Py_RETURN_NONE;
+ }
+}
+
+static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNUSED(closure))
+{
+ BMesh *bm = self->bm;
+ if (value == Py_None) {
+ bm->act_face = NULL;
+ return 0;
+ }
+ else if (BPy_BMFace_Check(value)) {
+ BPY_BM_CHECK_INT(value);
+
+ if (((BPy_BMFace *)value)->bm != bm) {
+ PyErr_SetString(PyExc_ValueError,
+ "faces.active = f: f is from another mesh");
+ return -1;
+ }
+ else {
+ bm->act_face = ((BPy_BMFace *)value)->f;
+ return 0;
+ }
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "faces.active = f: expected BMFace or None, not %.200s",
+ Py_TYPE(value)->tp_name);
+ return -1;
+ }
+}
+
static PyGetSetDef bpy_bmesh_getseters[] = {
{(char *)"verts", (getter)bpy_bmvertseq_get, (setter)NULL, (char *)bpy_bmvertseq_doc, NULL},
{(char *)"edges", (getter)bpy_bmedgeseq_get, (setter)NULL, (char *)bpy_bmedgeseq_doc, NULL},
@@ -676,6 +723,8 @@
};
static PyGetSetDef bpy_bmfaceseq_getseters[] = {
{(char *)"layers", (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_FACE},
+ /* face only */
+ {(char *)"active", (getter)bpy_bmfaceseq_active_get, (setter)bpy_bmfaceseq_active_set, (char *)bpy_bmfaceseq_active_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
static PyGetSetDef bpy_bmloopseq_getseters[] = {
More information about the Bf-blender-cvs
mailing list