Running code manually after script is loaded / executed

Hi,

I’ve made an small add-on. It works nice, but I want to be able to create another script that should run methods from my add-on. Is this possible?

For example, my add-on has a method
bpy.ops.object.test_method()
but if I try to run it from the python console it does not work the same way than if I press a UI button on the add-on that fires it.

Also, how can I use parameters for these methods?

Can I use a Class I’ve created in this add-on?

Example:


class MyTools():
    def sayHello():
        print("Hello");
        return;

How can I use this class on the python console once I’ve run the script on the text editor?

Thank you very much for your time.

For something like this I would start with getting the code working in vanilla Python first. I’m not sure you could easily prototype this using the Python Console. I don’t have code in front of me, but I think it was as simple as this might work.


#==================
# file foo.py
#==================
def foo_func():
    print("hello from foo.py!")


#==================
# file bar.py
#==================
from foo import foo_func
print("inside bar.py")
foo_func()

Save both files in same directory, then run bar.py from a command line terminal or Python’s Idle editor.