Last active
March 24, 2022 06:22
-
-
Save mnmly/59244e79cbc7954320bed532ae6c2cf4 to your computer and use it in GitHub Desktop.
make iterations into keyframes #blender #bpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import bpy | |
iteration_items = [] | |
for item in bpy.data.objects: | |
if 'Block__Iteration' in item.name_full: | |
iteration_items.append(item) | |
prev_name = None | |
frame_index = -1 | |
for j in range(50): | |
for i, item in enumerate(iteration_items): | |
item.hide_viewport = item.hide_render = True | |
item.keyframe_insert('hide_viewport', frame=j, options={'INSERTKEY_REPLACE'}) | |
item.keyframe_insert('hide_render', frame=j, options={'INSERTKEY_REPLACE'}) | |
for i, item in enumerate(iteration_items): | |
pattern = r'\.\d+' | |
item_name = re.sub(pattern, '', item.name_full) | |
if item_name != prev_name: | |
frame_index = frame_index + 1 | |
item.hide_viewport = item.hide_render = False | |
item.keyframe_insert('hide_viewport', frame=frame_index, options={'INSERTKEY_REPLACE'}) | |
item.keyframe_insert('hide_render', frame=frame_index, options={'INSERTKEY_REPLACE'}) | |
prev_name = item_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment