1
$\begingroup$

I'm trying to figure out a workflow to allow me to develop addons in Blender that doesn't require me to use the Scripting window. The scripting window is great if your script can be done in a single page, but breaks down when you need to break your code into more than one file. It also causes problems because what you have in the script window may get out of sync with what you have saved to disk.

The only alternative I see is to keep recompiling/uninstalling/reinstalling my addon. (By recompile, I mean running a script I've created to bundle my source files into a zip ready for deployment). However, it takes a lot of mouse clicks in the Preferences dialog to remove your old addon and then install the latest version. That's a lot of work to do every time you make a change.

I'm seeing some references to 'reloading addons' by pressing F8 in other posts, but I don't see how that will help since I would still need to rebuild/reinstall my plugin.

Is there a more developer friendly way to go about developing an addon?

$\endgroup$
2
4
$\begingroup$

Have a look at Blender's add-ons folder for many examples. C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons if you are on Windows.

Let's have a look at MeasureIt add-on for example. It has multiple files:

enter image description here

If you open the __init__.py, you can see that measureit_main is imported

enter image description here

and if you open it, you can see other imports:

enter image description here

.zip files that you use to install the add-ons are just simple zip files containing a folder named after the add-on and all the files in it.

You could also have a look at How to run a python script external to Blender to run bpy commands in Blender'spython console

$\endgroup$
8
  • $\begingroup$ Okay, but how would I install that? As far as I can tell, the addon installer only accepts zip files. $\endgroup$
    – kitfox
    Feb 3 at 8:47
  • $\begingroup$ I edited the answer. They are just simple .zip archives that you can make with utilities like 7zip or similar and they contain a folder named after the addon and all the files in it. $\endgroup$ Feb 3 at 8:54
  • $\begingroup$ Well, that's the problem. What I'm looking for is an efficient way to write/debug where I can have Blender reload my code every time I make a change. If I have to rebuild my zip, uninstall the old version and then reinstall the new one every time I change a line, it is a huge drag on my development time. $\endgroup$
    – kitfox
    Feb 3 at 8:56
  • 2
    $\begingroup$ I see. Don't install a zip file, just have a folder in %appdata%\Blender Foundation\Blender\2.91\scripts\addons with your files. If the addon is enabled in the preferences it will be reloaded every time you use Reload Scripts operator in Blender. Search for it with F3 by name or make a hotkey maybe. Once you are done developing, pack everything to a zip. It's here as well: i.imgur.com/UZFcjx7.png $\endgroup$ Feb 3 at 9:02
  • $\begingroup$ Please post scripts as text. $\endgroup$
    – batFINGER
    Feb 3 at 9:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.