Hi
I´m new to scripting.
I tried to write a script to animate the objects visibility/ renderability on one layer.
I managed to change it for ONE activated object.
How can I change it for all objects on the layer?
I can select them all by using:
bpy.ops.object.select_by_layer(extend=False, layers=1)
but then only the last one is set active.
Do I have to write a range?(but I do not know how to do that)
I know there is the trick to use only one active layer and move the objects to that layer at a particular frame. But the file has many objects.
It would be nice if you can help me, here is the script (don´t laugh, it´s very small;):
import bpy
def restrict_render_test():
ob = bpy.context.active_object
scene = bpy.context.scene
scene.frame_set(1)
ob.hide= True
ob.hide_render=True
ob.keyframe_insert(data_path= “hide”)
ob.keyframe_insert(data_path= “hide_render”)
scene.frame_set(10)
ob.hide= False
ob.hide_render=False
ob.keyframe_insert(“hide”)
ob.keyframe_insert(“hide_render”)
restrict_render_test()
or is it easier to work with:
bpy.ops.outliner.visibility_toggle()
but I do not know how to use it.
what is the best way?