1

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?

kitfox
  • 1,616
  • 5
  • 26
  • 40
  • https://blender.stackexchange.com/questions/158775/having-trouble-creating-an-addon-with-multiple-modules/158787#158787 Reload is also available via Blender > System > Reload Scripts menu. Top RH corner icon. – batFINGER Feb 03 '21 at 09:09
  • see https://blender.stackexchange.com/questions/183773/trying-to-make-a-menu-using-multiple-modules/183817#183817 If you use an absolute import based on your addon name can (in many cases) run scripts individually from the text editor. – batFINGER Feb 03 '21 at 09:23

1 Answers1

4

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

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
  • Okay, but how would I install that? As far as I can tell, the addon installer only accepts zip files. – kitfox Feb 03 '21 at 08:47
  • 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. – Martynas Žiemys Feb 03 '21 at 08:54
  • 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. – kitfox Feb 03 '21 at 08:56
  • 2
    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: https://i.imgur.com/UZFcjx7.png – Martynas Žiemys Feb 03 '21 at 09:02
  • Please post scripts as text. – batFINGER Feb 03 '21 at 09:16
  • These are only to illustrate where the info can be found. I would like to encourage the OP to study the add-ons as examples and find whatever suits his situation best instead of necessarily using this what I found in 30 seconds without much thought. – Martynas Žiemys Feb 03 '21 at 09:24
  • But sure here are the two words for someone who might want to copy and paste them without typing: from and import :D – Martynas Žiemys Feb 03 '21 at 09:27
  • Please read https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557 – batFINGER Feb 04 '21 at 09:00