12
$\begingroup$

I am a keen user of Bassam's typewriter.py addon. It's not part of the official distribution, so I thought I could make my .blend projects more portable by including it as a text block.

I always need to run the block even though I checked the register checkbox. Are there any more requirements to having the .py extension that I need to do before the script will run on load?

$\endgroup$
0

1 Answer 1

15
$\begingroup$

Yes, if the addon is a single file (rather then a python package containing an __init__.py file).

At the end of the script, remove these two lines:

if __name__ == "__main__":
    register()

And add this line:

register()

In Python __name__ refers to the module name, which in this case is the name of the textblock (without .py, however if you run the script directly __name__ will be "__main__").

Removing this check before calling the register() function will run no matter how its executed.


Note, if you do this - The script won't be listed in the preferences as an addon, this wont cause problems, but a user has no way to disable besides restarting blender.

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .