How to get lamp object?
def test(): Lights = bpy.data.lamps for light in Lights: light.use_nodes = True; light.type="POINT"; AdddLightIes(light)
#how to get light.object? and set position?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Blender object basics.
The lamp objects in
bpy.data.lamps is the data part of a lamp object
o. A lamp object has
o.type == "LAMP" and
o.data is a lamp object from
To get all lamp objects in file
lamp_objects = [o for o in bpy.data.objects if o.type == 'LAMP']
all in file that use a lamp named "Lamp"
lamp = bpy.data.lamps.get("Lamp") lamp_objects = [o for o in bpy.data.objects if o.type == 'LAMP' # need this since and o.data is lamp] # o.data is None for empties
for all in context scene
scene = bpy.context.scene lamp_objects = [o for o in scene.objects if o.type == 'LAMP']
for all in context selected objects
lamp_objects = [o for o in bpy.context.selected_objects if o.type == 'LAMP']
To move all lamps to local position (0, 0, 0)
for o in lamp_objects: o.location = (0, 0, 0)
To move all lamps to global origin
for o in lamp_objects: o.matrix_world.translation = (0, 0, 0)