def setMesh(bmesh, ob, matrix = None) : """ Update a mesh from a bmesh object """ #Before setting mesh data assign matrix: if matrix is not None : ob.matrix_world = matrix bmesh.normal_update() bmesh.to_mesh(ob.data) return ob
def setMesh(bmesh, ob, matrix=None): """ Update a mesh from a bmesh object """ #Before setting mesh data assign matrix: if matrix is not None: ob.matrix_world = matrix bmesh.normal_update() bmesh.to_mesh(ob.data) return ob
def setNamedMesh(bmesh, object_name, scene = None, matrix = None) : """ Update a mesh from a bmesh object name """ try : ob = getObject(object_name) #Before setting mesh data assign matrix: if matrix is not None : ob.matrix_world = matrix bmesh.normal_update() bmesh.to_mesh(ob.data) return ob except : return createMesh(bmesh, scene, object_name)
def setNamedMesh(bmesh, object_name, scene=None, matrix=None): """ Update a mesh from a bmesh object name """ try: ob = getObject(object_name) #Before setting mesh data assign matrix: if matrix is not None: ob.matrix_world = matrix bmesh.normal_update() bmesh.to_mesh(ob.data) return ob except: return createMesh(bmesh, scene, object_name)
def createMesh(bmesh, scene = None, matrix = None, name = "Object") : """ Create a blender mesh object from a specified bmesh and context bmesh: Mesh to create a object for scene: Scene the new object will be added to name: Name of the object added """ mesh = bpy.data.meshes.new(name + "_Mesh") # create a new mesh with the name newOb = bpy.data.objects.new(name, mesh) # create an object with that mesh if matrix is not None : newOb.matrix_world = matrix #Link to scene if scene is not None : scene.objects.link(newOb) #Set bmesh bmesh.normal_update() bmesh.to_mesh(newOb.data) return newOb
def createMesh(bmesh, scene=None, matrix=None, name="Object"): """ Create a blender mesh object from a specified bmesh and context bmesh: Mesh to create a object for scene: Scene the new object will be added to name: Name of the object added """ mesh = bpy.data.meshes.new(name + "_Mesh") # create a new mesh with the name newOb = bpy.data.objects.new(name, mesh) # create an object with that mesh if matrix is not None: newOb.matrix_world = matrix #Link to scene if scene is not None: scene.objects.link(newOb) #Set bmesh bmesh.normal_update() bmesh.to_mesh(newOb.data) return newOb