-
-
Save zeffii/8a5a7191169c69636594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_bix2(): | |
obj = bpy.context.edit_object | |
me = obj.data | |
bm = bmesh.from_edit_mesh(me) | |
bm.verts.ensure_lookup_table() | |
bm.edges.ensure_lookup_table() | |
bm.faces.ensure_lookup_table() | |
bm_verts = bm.verts | |
bm_edges = bm.edges | |
bm_faces = bm.faces | |
edges = [e for e in bm_edges if e.select] | |
if not len(edges) == 2: | |
print('select only two edges') | |
return | |
itxs = [set(e.link_faces) for e in edges] | |
itx = itxs[0] & itxs[1] | |
if not (len(itx) == 1): | |
print('two edges do not share a face..') | |
return | |
itx = itx.pop(); print('face idx =', itx.index) | |
verts = [set(e.verts) for e in edges] | |
v = verts[0] & verts[1] | |
v = v.pop(); print('vertex index: ', v.index, v.co) | |
vopp = verts[0] ^ verts[1] | |
v1 = vopp.pop() | |
v2 = vopp.pop() | |
v11 = (v1.co - v.co).normalized() | |
v22 = (v2.co - v.co).normalized() | |
plane_no = v11 - v22 | |
plane_co = v.co | |
dist = 0.0001 | |
print('face to cut', [bm_faces[itx.index]]) | |
visible_geom = [g for g in bm.faces[:] | |
+ bm.verts[:] + bm.edges[:] if not g.hide] | |
bmesh.ops.bisect_plane( | |
bm, | |
# geom=[bm_faces[itx.index]], | |
geom=visible_geom, | |
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