I am having a "python script fail" on my project that I am working on and I do not know why. my script is programmed to turn on one lamp at a time and render an image with a different lamp turned on for each render.
import bpy, bgl, blf,sys
sceneKey = bpy.data.scenes.keys()[0]
filepath = "G:\rtitrial2"
# Loop all objects and try to find the Lamps
print ('Looping Lamps')
l=0
# first run through all of the lamps turning them off
for obj in bpy.data.objects:
if ( obj.type =='LAMP'):
obj.hide_render = True
l = l + 1
print('You have hidden ' + str(l) + "lamps")
# now we can go through and
# individually turn them on
# and render out a picture
for obj in bpy.data.objects:
if ( obj.type =='LAMP'):
print (obj.name)
obj.hide_render = False
bpy.data.scenes[sceneKey].render.image_settings.file_format = 'JPEG'
bpy.data.scenes[sceneKey].render.filepath = filepath + '//lamp_' +
str(obj.name)
# Render Scene and store the scene
bpy.ops.render.render( write_still=True )
obj.hide_render = True
lamps = [o for o in scene.objects if o.type == 'LAMP']
can be iterated withfor lamp in lamps:
and haslen(lamps)
members. $\endgroup$