In the api I found this code
import bpy view_layer = bpy.context.view_layer # Create new light datablock. light_data = bpy.data.lights.new(name="New Light", type='POINT') # Create new object with our light datablock. light_object = bpy.data.objects.new(name="New Light", object_data=light_data) # Link light object to the active collection of current view layer, # so that it'll appear in the current scene. view_layer.active_layer_collection.collection.objects.link(light_object) # Place light to a specified location. light_object.location = (5.0, 5.0, 5.0) # And finally select it and make it active. light_object.select_set(True) view_layer.objects.active = light_object
It works in blender 2.82 but it is impossible to find anything about the “objects.active” element. I tried to do it again from the scene but the console tells me that the active property doesn’t exist. I don’t understand.
Is it possible to directly target an object to make it active, or to do it from the scene?
Have a nice day,