Skip to content

Vendor & Package blendcss ​

This guide shows how to bundle blendcss inside your Blender addon, register multiple panels safely, and package your addon as a Blender 4.2+ Extension.

Vendor blendcss/ into your addon ​

Copy the blendcss/ directory directly into your addon package and import it with a relative import:

text
my_addon/
├── __init__.py
├── blender_manifest.toml   # Optional: required for Blender 4.2+ Extensions
├── panels/
│   ├── main_panel.py
│   └── export_panel.py
└── blendcss/
    ├── __init__.py
    ├── panel.py
    ├── ui.py
    ├── core/
    ├── widgets/
    └── binaries/
        ├── my_engine.cp311-win_amd64.pyd
        ├── my_engine.cp313-win_amd64.pyd
        ├── my_engine.cpython-311-x86_64-linux-gnu.so
        ├── my_engine.cpython-313-x86_64-linux-gnu.so
        ├── rmlui_engine.cp311-win_amd64.pyd
        ├── rmlui_engine.cp313-win_amd64.pyd
        ├── rmlui_engine.cpython-311-x86_64-linux-gnu.so
        └── rmlui_engine.cpython-313-x86_64-linux-gnu.so

Inside your addon code, always use a relative import so your addon loads its own vendored copy:

python
from . import blendcss
# or from a submodule such as panels/main_panel.py:
from .. import blendcss

Keep the binaries/ folder intact

blendcss/binaries/ contains the compiled native extensions (.pyd) for Python 3.11 (Blender 4.2–4.5) and Python 3.13 (Blender 5.0+). Removing a .pyd file for your user's Blender Python version will prevent blendcss from rendering.

Isolate your addon with addon_id ​

Set a unique addon_id on every blendcss.Panel subclass in your addon:

python
class MainPanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Main Controls"
    order = 0
    ...


class ExportPanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Export Settings"
    order = 1
    ...

Why this matters:

  • Panels with the same addon_id automatically share one GpuManager and one modal event operator ({addon_id}.gpu_panel_handler).
  • Panels from different addons use different addon_id values and never collide in Blender's operator registry or draw handlers.

Register and unregister multiple panels ​

Pass all your panel classes to blendcss.register(...) and blendcss.unregister(...) in one call:

python
from . import blendcss
from .panels.main_panel import MainPanel
from .panels.export_panel import ExportPanel

PANELS = (MainPanel, ExportPanel)


def register():
    blendcss.register(PANELS)


def unregister():
    blendcss.unregister(PANELS)

When the last panel for an addon_id is unregistered, blendcss automatically tears down its shared GpuManager and releases GPU resources.

Control panel placement and visibility ​

blendcss.Panel exposes standard Blender panel metadata attributes:

python
class MeshOnlySubPanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Mesh Helpers"
    idname = "MYADDON_PT_mesh_helpers"
    parent_id = "MYADDON_PT_main_controls"  # Nest as a collapsible sub-panel
    options = {'DEFAULT_CLOSED'}
    order = 2

    @classmethod
    def poll(cls, context):
        obj = context.active_object
        return obj is not None and obj.type == 'MESH'

Package as a Blender 4.2+ Extension ​

When shipping as a Blender Extension, declare platforms = ["windows-x64", "linux-x64"] in blender_manifest.toml to match the prebuilt native modules in blendcss/binaries/:

toml
schema_version = "1.0.0"
id = "my_addon"
version = "1.0.0"
name = "My Addon"
tagline = "Short description of your addon"
maintainer = "Your Name"
type = "add-on"

blender_version_min = "4.2.0"
platforms = ["windows-x64", "linux-x64"]
license = ["SPDX:GPL-3.0-or-later"]

For full details on Panel registration attributes, see the Panel API Reference.

Released under the GNU GPL v3.0 License.