Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-05 22:42:00 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-05 22:42:00 +0300
commita22167b9a2fec63b6da419f7a42075d4b722b950 (patch)
treee5c83dbe9659fc89aad9e0e81338b7c5da9820a5 /doc
parent5ae853d20a3a5e41660220e684be1c7b785256d2 (diff)
Fix/Updated Object API example.
Was still 2.7x code... ;)
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/examples/bpy.types.Object.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/doc/python_api/examples/bpy.types.Object.py b/doc/python_api/examples/bpy.types.Object.py
index 90c50bcfad7..f141ac7ce0f 100644
--- a/doc/python_api/examples/bpy.types.Object.py
+++ b/doc/python_api/examples/bpy.types.Object.py
@@ -3,26 +3,27 @@ Basic Object Operations Example
+++++++++++++++++++++++++++++++
This script demonstrates basic operations on object like creating new
-object, placing it into scene, selecting it and making it active.
+object, placing it into a view layer, selecting it and making it active.
"""
import bpy
from mathutils import Matrix
-scene = bpy.context.scene
+view_layer = bpy.context.view_layer
-# Create new lamp datablock
-lamp_data = bpy.data.lamps.new(name="New Lamp", type='POINT')
+# Create new light datablock.
+light_data = bpy.data.lights.new(name="New Light", type='POINT')
-# Create new object with our lamp datablock
-lamp_object = bpy.data.objects.new(name="New Lamp", object_data=lamp_data)
+# Create new object with our light datablock.
+light_object = bpy.data.objects.new(name="New Light", object_data=light_data)
-# Link lamp object to the scene so it'll appear in this scene
-scene.objects.link(lamp_object)
+# Link light object to the active collection of current view layer,
+# so that it'll appear in the current scene.
+view_layer.collections.active.collection.objects.link(light_object)
-# Place lamp to a specified location
-lamp_object.location = (5.0, 5.0, 5.0)
+# Place light to a specified location.
+light_object.location = (5.0, 5.0, 5.0)
-# And finally select it make active
-lamp_object.select = True
-scene.objects.active = lamp_object
+# And finally select it and make it active.
+light_object.select_set('SELECT')
+view_layer.objects.active = light_object