Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import bmesh
- def main(context):
- context = bpy.context
- ob = context.edit_object
- me = ob.data
- bm = bmesh.from_edit_mesh(me)
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
- originalEdges = set(e for e in bm.edges if e.select)
- bpy.ops.mesh.poke()
- allEdges = set(e for e in bm.edges if e.select)
- bpy.ops.mesh.region_to_loop()
- borderEdges = set(e for e in bm.edges if e.select)
- diamondEdges = allEdges - originalEdges - borderEdges
- originalWithoutBorder = originalEdges - borderEdges
- bpy.ops.mesh.select_all(action='DESELECT')
- for e in originalWithoutBorder:
- e.select = True
- bpy.ops.mesh.dissolve_mode(use_verts=True)
- for e in diamondEdges:
- e.select = True
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
- bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
- newFaces = set(f for f in bm.faces if f.select)
- bpy.ops.mesh.select_face_by_sides(number=3, type='EQUAL', extend=False)
- triangleFaces = set(f for f in bm.faces if f.select)
- newFaces = newFaces - triangleFaces
- bpy.ops.mesh.select_all(action='DESELECT')
- for f in newFaces:
- f.select = True
- bmesh.update_edit_mesh(me)
- class VitalyPoke(bpy.types.Operator):
- """
- [Vitaly Poke]
- Description:
- Uses the Poke operator and some caveman code to convert a selection of quads into diamond-looking faces
- """
- bl_idname = "arc.vitaly_poke"
- bl_label = "Vitaly Poke (ARC)"
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
- def execute(self, context):
- main(context)
- return {'FINISHED'}
- def register():
- bpy.utils.register_class(VitalyPoke)
- def unregister():
- bpy.utils.unregister_class(VitalyPoke)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement