Here's a script to make visible only one object per frame in Blender. Visibility goes on for a single object and off for the rest.
import bpy
def ani_handler(scene):
obj_len = len(scene.objects.values())
for i, obj in enumerate(scene.objects.values()):
# obj.hide_set(i != ((scene.frame_current-1) % obj_len)) # Blender 2.80
obj.hide = (i != ((scene.frame_current-1) % obj_len)) #Blender 2.79b
bpy.app.handlers.frame_change_post.append(ani_handler)
Here's a second iteration of the script, this time it only changes visibility for objects with a specific name. In this case Cube
import bpy
def ani_handler(scene):
name = 'Cube'
objs = [obj for obj in scene.objects.values() if name in obj.name]
for i, obj in enumerate(objs):
obj.hide_set(i != ((scene.frame_current-1) % len(objs))) # Blender 2.80
# obj.hide = (i != ((scene.frame_current-1) % obj_len)) #Blender 2.79b
bpy.app.handlers.frame_change_pre.append(ani_handler)
No comments:
Post a Comment