Changeset View
Changeset View
Standalone View
Standalone View
doc/python_api/examples/bpy.types.Operator.py
| Show All 16 Lines | |||||
| class HelloWorldOperator(bpy.types.Operator): | class HelloWorldOperator(bpy.types.Operator): | ||||
| bl_idname = "wm.hello_world" | bl_idname = "wm.hello_world" | ||||
| bl_label = "Minimal Operator" | bl_label = "Minimal Operator" | ||||
| def execute(self, context): | def execute(self, context): | ||||
| print("Hello World") | print("Hello World") | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| # Only needed if you want to add into a dynamic menu | |||||
| def menu_func(self, context): | |||||
| self.layout.operator(HelloWorldOperator.bl_idname, text="Hello World Operator") | |||||
| # Register and add to the file selector | |||||
lichtwerk: please add the //(required to use F3 search....// part here as well | |||||
| bpy.utils.register_class(HelloWorldOperator) | bpy.utils.register_class(HelloWorldOperator) | ||||
| bpy.types.VIEW3D_MT_view.append(menu_func) | |||||
| # test call to the newly defined operator | # test call to the newly defined operator | ||||
| bpy.ops.wm.hello_world() | bpy.ops.wm.hello_world() | ||||
please add the (required to use F3 search.... part here as well