__author__ = 'thoth'
#
# alter the list of layers that are part of the scene to match the layers that are active in all the RenderLayers
#
import bpy
def set_scene_layers_from_render_layers(scn = bpy.context.scene):
layers = [ False for i in range(len(scn.layers))]
for l in scn.render.layers:
for i in range(len(layers)):
if l.layers[i]:
layers[i] = True
scn.layers = layers
def explode_if_layers_wrong(scn = bpy.context.scene):
for l in scn.render.layers:
for i in range(len(scn.layers)):
if l.layers[i] and not scn.layers[i]:
raise BaseException("scene layers missing %d used by %s"%(i, l.name))
if __name__ == "__main__":
bpy.app.handlers.render_pre.append(explode_if_layers_wrong)
# bpy.app.handlers.render_pre.append(set_scene_layers_from_render_layers)
print(__name__)
|
Blender python API quick-start
Syntax highlighting by Pygments.