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
diff options
context:
space:
mode:
Diffstat (limited to 'doc/python_api/examples/bpy.types.Operator.py')
-rw-r--r--doc/python_api/examples/bpy.types.Operator.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.Operator.py b/doc/python_api/examples/bpy.types.Operator.py
new file mode 100644
index 00000000000..52edfa0a61b
--- /dev/null
+++ b/doc/python_api/examples/bpy.types.Operator.py
@@ -0,0 +1,27 @@
+"""
+Basic Operator Example
+++++++++++++++++++++++
+This script shows simple operator which prints a message.
+
+Since the operator only has an :class:`Operator.execute` function it takes no
+user input.
+
+.. note::
+
+ Operator subclasses must be registered before accessing them from blender.
+"""
+import bpy
+
+
+class HelloWorldOperator(bpy.types.Operator):
+ bl_idname = "wm.hello_world"
+ bl_label = "Minimal Operator"
+
+ def execute(self, context):
+ print("Hello World")
+ return {'FINISHED'}
+
+bpy.utils.register_class(SimpleOperator)
+
+# test call to the newly defined operator
+bpy.ops.wm.hello_world()