Skip to content

Instantly share code, notes, and snippets.

@softyoda
Created July 7, 2022 11:06
Show Gist options
  • Save softyoda/bc4d15da09a1708c053f6989c9030646 to your computer and use it in GitHub Desktop.
Save softyoda/bc4d15da09a1708c053f6989c9030646 to your computer and use it in GitHub Desktop.
blender_mirror_performance
import bpy
bpy.ops.mesh.primitive_monkey_add(size=2, enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].levels = 3
bpy.ops.object.modifier_apply(modifier="Subdivision")
bpy.ops.object.modifier_add(type='ARRAY')
bpy.context.object.modifiers["Array"].count = 50
bpy.ops.object.modifier_apply(modifier="Array")
bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.modifier_apply(modifier="Mirror") #Comment this line to see CONSIDERABLE lost of performance
for i in range (250): #add 25 keyframes
bpy.context.scene.frame_current = i
bpy.ops.transform.rotate(value=i/10, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.ops.anim.keyframe_insert_by_name(type="Rotation")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment