def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
assert(obj.type == 'MESH')
if apply_modifiers and obj.modifiers:
import bpy
me = obj.to_mesh(bpy.context.scene, True, 'PREVIEW', calc_tessface=False)
bm = bmesh.new(); bm.from_mesh(me); bpy.data.meshes.remove(me)
del bpy
else:
me = obj.data
if obj.mode == 'EDIT': bm_orig = bmesh.from_edit_mesh(me); bm = bm_orig.copy()
else: bm = bmesh.new(); bm.from_mesh(me)
if transform: bm.transform(obj.matrix_world)
if triangulate: bmesh.ops.triangulate(bm, faces=bm.faces)
return bm
评论列表
文章目录