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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-06-06 14:01:17 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-06-06 14:01:17 +0400
commit8849a789702a9be0c06ecc850845c3bb3af0d0fd (patch)
tree35b862f11bce49fe7488eed4f2add016a832b9ff /doc
parent8b7538ce946b5265bcc065e518716b2ffb9fda53 (diff)
Added example of basic objects ooperations in Python, liek adding object
datablock, adding object, linking it to scene and making selected and active.
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/examples/bpy.types.Object.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.Object.py b/doc/python_api/examples/bpy.types.Object.py
new file mode 100644
index 00000000000..5301797aae2
--- /dev/null
+++ b/doc/python_api/examples/bpy.types.Object.py
@@ -0,0 +1,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
+"""
+
+import bpy
+from mathutils import Matrix
+
+scene = bpy.context.scene
+
+# Create new lamp datablock
+lamp_data = bpy.data.lamps.new(name="New Lamp", type="POINT")
+
+# Create new object with out lamp datablock
+lamp_object = bpy.data.objects.new(name="New Lamp", object_data=lamp_data)
+
+# Link lamp object to the scene so it'll appear in this scene
+scene.objects.link(lamp_object)
+
+# Place lamp to specified location
+lamp_object.location = (5.0, 5.0, 5.0)
+
+# And finally select it make active
+lamp_object.select = True
+scene.objects.active = lamp_object