[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44353] trunk/blender/source/blender/ python/bmesh/bmesh_py_types.c: bmesh py api, more wrapped funcs:

Campbell Barton ideasman42 at gmail.com
Thu Feb 23 05:19:33 CET 2012


Revision: 44353
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44353
Author:   campbellbarton
Date:     2012-02-23 04:19:25 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
bmesh py api, more wrapped funcs:
* BMFace.copy(verts=True, faces=Trur)
* BMEdge.other_vert(vert)

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-02-23 03:39:39 UTC (rev 44352)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2012-02-23 04:19:25 UTC (rev 44353)
@@ -660,9 +660,81 @@
 	return PyFloat_FromDouble(BM_edge_face_angle(self->bm, self->e));
 }
 
+PyDoc_STRVAR(bpy_bmedge_other_vert_doc,
+             ".. method:: other_vert(vert)\n"
+             "\n"
+             "   Return the other vertex on this edge or None if the vertex is not used by this edge.\n"
+             );
+static PyObject *bpy_bmedge_other_vert(BPy_BMEdge *self, BPy_BMVert *value)
+{
+	BMVert *other;
+	BPY_BM_CHECK_OBJ(self);
+
+	if (!BPy_BMVert_Check(value)) {
+		PyErr_Format(PyExc_TypeError,
+		             "BMEdge.other_vert(vert): BMVert expected, not '%.200s'",
+		             Py_TYPE(value)->tp_name);
+		return NULL;
+	}
+
+	BPY_BM_CHECK_OBJ(value);
+
+	if (self->bm != value->bm) {
+		PyErr_SetString(PyExc_TypeError,
+		                "BMEdge.other_vert(vert): vert is from another mesh");
+		return NULL;
+	}
+
+	other = BM_edge_other_vert(self->e, value->v);
+
+	if (other) {
+		return BPy_BMVert_CreatePyObject(self->bm, other);
+	}
+	else {
+		/* could raise an exception here */
+		Py_RETURN_NONE;
+	}
+}
+
 /* Face
  * ---- */
 
+PyDoc_STRVAR(bpy_bmface_copy_doc,
+             ".. method:: copy(verts=True, edges=True)\n"
+             "\n"
+             "   Return the area of the face.\n"
+             );
+static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw)
+{
+	static const char *kwlist[] = {"verts", "edges", NULL};
+
+	BMesh *bm = self->bm;
+	int do_verts = TRUE;
+	int do_edges = TRUE;
+
+	BMFace *f_cpy;
+	BPY_BM_CHECK_OBJ(self);
+
+	if (!PyArg_ParseTupleAndKeywords(args, kw,
+	                                 "|ii:BMFace.copy",
+	                                 (char **)kwlist,
+	                                 &do_verts, &do_edges))
+	{
+		return NULL;
+	}
+
+	f_cpy = BM_face_copy(bm, self->f, do_edges, do_verts);
+
+	if (f_cpy) {
+		return BPy_BMFace_CreatePyObject(bm, f_cpy);
+	}
+	else {
+		PyErr_SetString(PyExc_ValueError,
+		                "BMFace.copy(): couldn't create the new face, internal error");
+		return NULL;
+	}
+}
+
 PyDoc_STRVAR(bpy_bmface_calc_area_doc,
              ".. method:: calc_area()\n"
              "\n"
@@ -1039,6 +1111,8 @@
     {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
     {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
 
+    {"other_vert", (PyCFunction)bpy_bmedge_other_vert, METH_O, bpy_bmedge_other_vert_doc},
+
     {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc},
     {NULL, NULL, 0, NULL}
 };
@@ -1047,6 +1121,8 @@
     {"select_set", (PyCFunction)bpy_bm_elem_select_set, METH_O, bpy_bm_elem_select_set_doc},
     {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
 
+    {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS|METH_KEYWORDS, bpy_bmface_copy_doc},
+
     {"calc_area",          (PyCFunction)bpy_bmface_calc_area,          METH_NOARGS, bpy_bmface_calc_area_doc},
     {"calc_center_median", (PyCFunction)bpy_bmface_calc_center_mean,   METH_NOARGS, bpy_bmface_calc_center_mean_doc},
     {"calc_center_bounds", (PyCFunction)bpy_bmface_calc_center_bounds, METH_NOARGS, bpy_bmface_calc_center_bounds_doc},




More information about the Bf-blender-cvs mailing list