An open API service indexing awesome lists of open source software.

https://github.com/razcore-rad/blender-addon-dev-watcher

Hot-reload Blender addons during development
https://github.com/razcore-rad/blender-addon-dev-watcher

addon blender blender-addon blender-plugin development hot-reload hot-reloading live-reload live-reloading python watch watcher

Last synced: 8 days ago
JSON representation

Hot-reload Blender addons during development

Awesome Lists containing this project

README

          

# INFO

Tested with Blender 4.0.2.

# Blender Addon Dev Watcher

This addon auto-reloads the watched addons when file changes get detected for a fast development cycle.

It uses the Python [watchdog](https://github.com/gorakhargosh/watchdog) module.

## The Problem

Blender addon development is greatly slowed down due to lack of hot-reloading on file changes.

Some proposed workarounds include:

1. Refresh followed by disabling/enabling the addon from the `Preferences... > Add-ons` panel.
2. Using the `Reload Scripts` button.

![](readme/reload-scripts.png)

Both of these options are less than ideal.

## The Solution

This addon found under the `View 3D > Sidebar > Tool > Addon Dev Watcher` panel lists the available (user) addons in the top list apart from itself.

![](readme/addon-dev-watcher.png)

We can add any addon from the top list to the bottom list with the `Add Watch` button. This starts a `watchdog` process waiting for file changes in the respective addon. When such a file change is detected it auto-reloads that addon.

To remove an addon from the watch list use the `Remove Watch` button.

That's it, nice and simple.

## Notes

For now, there are no preference and the addon resets every time Blender is restart. This means that you have to actively add an addon to the watched list every restart.

The addon adds itself to the watch list and can't be unwatched. This is so we can hot-reload it during development at any time for whatever reason.

Refreshing the addon is done with the help of the `bpy.ops.preferences.addon_disable()`, `bpy.ops.preferences.addon_enable()` Blender function, and a solution to recursively reload modules from [this gist](https://gist.github.com/KristianHolsheimer/f139646259056c1dffbf79169f84c5de).

The watchdog dependency is installed in the `ADDON_PATH/dependnecies` local folder by creating a virtual environment using the `venv` module.