I'm working in Blender 2.8 and I'm new to python and scripting in general.
I have a file that contains multiple lighting fixtures (100+). I'm trying to write a script that will add a spot light to each fixture that I've selected.
Here's what I have so far:
import bpy
selected = bpy.context.selected_objects[0]
bpy.ops.object.light_add(type='SPOT', location=selected.location)
The issue is this script only adds a light to one object, not every object I've selected.
I haven't gotten to it yet, but I'd also like every light to have share the same light data, so they can all be changed at once.
Thanks in advanced for the help!
for item in bpy.context.selected_objects
$\endgroup$selected = bpy.context.selected_objects[0]
to another number, it changes the object that the lights are added to. $\endgroup$for item in bpy.context.selected_objects bpy.ops.object.light_add(type='SPOT', location=item.location)
. I'm not much of a coder myself, and I'm not even testing this so not sure it actually works. $\endgroup$for items in bpy.context.selected_objects: bpy.ops.object.light_add(type='SPOT', location=items.location)
does exactly what I need. Way more simple than I thought. Thanks for the help! $\endgroup$