# Animates the visiblity of line objects by changing their layers. Useful for # animating sequential appearance but does not alter the mesh geometry of the # lines - doesn't read in their original data. # This code is crude - it only checks that the objects are visible or not on # the correct layer. It doesn't do any checks to make sure that the objects # are ONLY in the correct layers, though this doesn't matter for us here. import bpy def animatelines(scene): frame = bpy.context.scene.frame_current for obj in bpy.data.objects: if 'Line_' in obj.name: index = int(obj.name.split('_')[1]) # Let's put objects we want visible on layer 1 if index <= frame: obj.layers[0] = True # Invisible objects should be on layer 2 but not layer 1 if index > frame: obj.layers[1] = True obj.layers[0] = False # Run the script every time the frame has changed bpy.app.handlers.frame_change_pre.append(animatelines)