Guest User

Untitled

a guest
Jan 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. def downLOD(context, ratio):
  2.     scene = bpy.context.scene
  3.     bpy.ops.object.mode_set(mode='OBJECT')
  4.    
  5.     bpy.context.scene.objects.active = None
  6.    
  7.     model = None
  8.     for obj in scene.objects:
  9.         obj.select = False
  10.         if obj.name != "Camera" and obj.name != "Lamp":
  11.             if model != None:
  12.                 raise Exception("model already found")
  13.             model = obj
  14.    
  15.     scene.objects.active = model
  16.     model.select = True
  17.        
  18.     bpy.ops.object.mode_set(mode='EDIT')
  19.     bpy.ops.mesh.select_all(action='SELECT')
  20.     bpy.ops.mesh.quads_convert_to_tris()
  21.     bpy.context.scene.update()
  22.     bpy.ops.object.mode_set(mode='OBJECT')
  23.    
  24.     bpy.ops.object.modifier_add(type='DECIMATE')
  25.     bpy.context.object.modifiers['Decimate'].ratio=ratio
  26.     bpy.ops.object.modifier_apply(modifier="Decimate")
Add Comment
Please, Sign In to add comment