Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def downLOD(context, ratio):
- scene = bpy.context.scene
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.context.scene.objects.active = None
- model = None
- for obj in scene.objects:
- obj.select = False
- if obj.name != "Camera" and obj.name != "Lamp":
- if model != None:
- raise Exception("model already found")
- model = obj
- scene.objects.active = model
- model.select = True
- bpy.ops.object.mode_set(mode='EDIT')
- bpy.ops.mesh.select_all(action='SELECT')
- bpy.ops.mesh.quads_convert_to_tris()
- bpy.context.scene.update()
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.modifier_add(type='DECIMATE')
- bpy.context.object.modifiers['Decimate'].ratio=ratio
- bpy.ops.object.modifier_apply(modifier="Decimate")
Add Comment
Please, Sign In to add comment