Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_random_color():
- ''' generate rgb using a list comprehension '''
- r, g, b = [random.random() for i in range(3)]
- return r, g, b, 1
- def createMeshFromData(name, origin, verts, faces):
- # Create mesh and object
- me = bpy.data.meshes.new(name + 'Mesh')
- ob = bpy.data.objects.new(name, me)
- ob.location = origin
- ob.show_name = True
- # Link object to scene and make active
- scn = bpy.context.scene
- scn.objects.link(ob)
- scn.objects.active = ob
- ob.select = True
- ob.color = get_random_color()
- # Create mesh from given verts, faces.
- me.from_pydata(verts, [], faces)
- # Update mesh with new data
- me.update()
- return ob
Add Comment
Please, Sign In to add comment