I'm just getting started with bpy and I wish to know how can I execute the addon below from the console.
# hello_world.py
bl_info = {
"name": "Hello World",
"category": "Object",
}
import bpy
class HelloWorld(bpy.types.Operator):
"""Print in the System Console"""
bl_idname = "object.hello_world"
bl_label = "Hello World"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
print("Hello, world!")
return {'FINISHED'}
def register():
bpy.utils.register_class(HelloWorld)
def unregister():
bpy.utils.unregister_class(HelloWorld)
I tried:
import hello_world
hello_world = hello_world.HelloWorld
hello_world
>>> <class 'hello_world.HelloWorld'>
hello_world.execute
>>> <function HelloWorld.execute at 0x0000009F05C576A8>
But it did not really execute. Whatever if it is a print function or an object translation it did not execute. What am I doing wrong?
I can execute the script from the space bar, typing the label Hello World
but I wish to call a variable from an addon and use it in a different addon. Thanks!