bpy.ops.object.lamp_add(type='POINT', radius=1, view_align=False, location=(1,1,1), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
new_name = bpy.context.active_object.name
bpy.data.lamps[new_name].use_nodes = True
bpy.data.lamps[new_name].node_tree.nodes["Emission"].inputs['Strength'].default_value = 3.0
I am trying to create a series of point source lamps (100s of them) using a script and then change the emission strength of each of them to a custom value - a different value for each light.
Most of the time the above code works. However, every now and again there seems to be a mismatch between the name of the object and some underlying object that it is linked to - see screenshot for example.
In this case my newly created object is called "Point.001", whereas it is linked to some object called "Point.038". Changing the node values for "Point.001" does nothing (as far as I can tell), I need to change the values for "Point.038". The issue is that I cannot figure out how to access the name "Point.038" via Python script. I assume since "Point.038" and "Point.001" are linked in the outliner, there has to be some way to traverse from "Point.001" to "Point.038".
An added wrinkle here is that each point source has a emission custom value, so I can't just cycle through every point light source object and change the value - I need to know that "Point.038" gets the emission that should be assigned "Point.001".