Cleanup: unused imports
[blender.git] / doc / python_api / examples / bpy.types.Object.py
1 """
2 Basic Object Operations Example
3 +++++++++++++++++++++++++++++++
4
5 This script demonstrates basic operations on object like creating new
6 object, placing it into a view layer, selecting it and making it active.
7 """
8
9 import bpy
10
11 view_layer = bpy.context.view_layer
12
13 # Create new light datablock.
14 light_data = bpy.data.lights.new(name="New Light", type='POINT')
15
16 # Create new object with our light datablock.
17 light_object = bpy.data.objects.new(name="New Light", object_data=light_data)
18
19 # Link light object to the active collection of current view layer,
20 # so that it'll appear in the current scene.
21 view_layer.active_layer_collection.collection.objects.link(light_object)
22
23 # Place light to a specified location.
24 light_object.location = (5.0, 5.0, 5.0)
25
26 # And finally select it and make it active.
27 light_object.select_set(True)
28 view_layer.objects.active = light_object