Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2014 10:29
Show Gist options
  • Save anonymous/11173399 to your computer and use it in GitHub Desktop.
Save anonymous/11173399 to your computer and use it in GitHub Desktop.
test
import bpy
import bmesh
import mathutils
import math
from mathutils import Vector
obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)
verts = [v for v in bm.verts if (v.select and not v.hide)]
#if not len(verts) == 2:
# msg = "select two vertices"
# self.report({"WARNING"}, msg)
# return
v1, v2 = [v.co for v in verts]
print('vectors found:\n', v1, '\n', v2)
## test if shared z values
#if not (v1.z == v2.z):
# msg = "vert must share at least the z component"
# self.report({"WARNING"}, msg)
# return
mid_vec = v1.lerp(v2, 0.5)
plane_no = v2-mid_vec
plane_co = mid_vec
dist = 0.0001
geom = [i for i in bm.faces]
bmesh.ops.bisect_plane(
bm, geom=bm.verts[:]+bm.edges[:]+bm.faces[:],
dist=dist,
plane_co=plane_co, plane_no=plane_no,
use_snap_center=False,
clear_outer=False,
clear_inner=False)
bmesh.update_edit_mesh(me, True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment