Hi together,
I have builded blender as a python module and it works fine. I am going to use this for an automatisation process without the blender software. In Blender (software), I have installed the add-on via Preferences - Add-on- install add-on, which is written in Python. My question now is, does somebody know, how I can integrate/register such an add-on in the blender build manually, without the install functionality from the Blender software?
The add-on I want to add is blender-osm (Blender-OSM: OpenStreetMap and Terrain for Blender) and an init.py with register() and unregister() is available.
You would help me a lot if you have a hint for me!
Best, Manuel
I have just started using the bpy
python module which is installable via pip
to run unit tests for the Molecular Nodes addon that I develop.
I found that if you add a pyproject.toml
then you can install the addon as a python module as well just with pip install ./MolecularNodes
.
Both blender and the addon will be available then inside of the python script, so you can import them like so:
import bpy
import MolecularNodes as mn
I have so far had lots of success with testing all of the functionality of the addon via this method.\
With @bunchofbradys approach I am able to import modules. The import is also possible with an import of absolute path in python scripts directly.
My problem is, that the addon is only working in the context of bpy (to build commands like bpy.context.scene.addon…) or scene. I have added the addon in addon_contrib folder in blender source code. To get it work, I need to register the addon somewhere in source code. Does somebody have a hint for me, where I can register python-written addons in blender sourcecode manually? This would help me a lot!
You can use the addon_utils
.
import bpy
import addon_utils
addon_utils.enable("your_add_on_name")
You can also use the register function that will be part of the python module that is your addon, which is defined in the __init__.py
.
In my example, this is what I do:
import molecularnodes as mn
mn.register()