Is there a way to load preset with python? I’m trying to make operator that adds a light, and then loads preset for that light. Like you can load from light properties panel
You can add a light with an operator, then customize it with a few more lines of code:
import bpy
# Add a light
bpy.ops.object.light_add(
type='POINT', # or 'SUN', 'SPOT', 'AREA'
radius=1,
location=(0, 0, 2)
)
# Now access the light we just added
light = bpy.data.lights[-1]
# Now set whatever properties you want
light.color = (1, 0, 0)
light.energy = 1000
Different lights have different properties, Spot will have Spot Size, Blend and Show Cone, Sun will have Angle, and Area will have shape, but the code above should work on any of them.
Does that answer your question?
No that’s not the point. I need loading presets specifically. I’m trying to create a script that automatically adds every light preset in Add menu, but loading presets is the hurdle
Ah, in that case, I guess I don’t know what a ‘preset’ is referring to in this context.