SHARE
TWEET

Untitled

a guest Jul 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import bpy
  2. import bmesh
  3. from mathutils import Matrix
  4. from math import pi
  5.  
  6. context = bpy.context
  7. ob = context.edit_object
  8. me = ob.data
  9.  
  10. bm = bmesh.from_edit_mesh(me)
  11.  
  12. f = bm.select_history.active
  13. if isinstance(f, bmesh.types.BMFace) and len(f.verts) == 3:
  14.     print("do it")
  15.     # longest edge
  16.     le = sorted(f.edges, key=lambda e: e.calc_length()).pop()
  17.     v = (set(f.verts) - set(le.verts)).pop()
  18.     nv = bm.verts.new(v.co)
  19.     bmesh.ops.rotate(bm,
  20.             cent=le.verts[0].co,
  21.             matrix=Matrix.Rotation(pi, 3, le.verts[0].co - le.verts[1].co),
  22.             verts = [nv],
  23.             )
  24.     bm.faces.new([nv] + le.verts[:]).select = True
  25.     #bmesh.ops.dissolve_edges(bm, edges=[le])
  26.     bm.normal_update()
  27.     bmesh.update_edit_mesh(me)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top