Extensions Index

Complementos#

Importante

This page is part of Extensions, and is only available experimentally in daily builds of Blender 4.2. Please enable «Extensions» on the Experimental Preferences to help testing it.

For the deprecated information about individual add-ons bundled with Blender visit Add-ons.

Add-ons let you extend Blender’s functionality using Python. Most of the time you can get add-ons as part of the Extensions system.

Truco

Si el complemento no se activa cuando está habilitado, consulte la ventana de la Consola para ver si hay algún error que pueda haber ocurrido.

Ruta de Complementos Definida por el Usuario#

También puede crear un directorio personal que contenga nuevos complementos y configurar la ruta de sus archivos en la sección Rutas de Archivo de Preferencias. Para crear un directorio de script personal:

  1. Cree un directorio vacío en una ubicación de su elección (por ejemplo, my_scripts).

  2. Agrega un subdirectorio bajo my_scripts llamado addons (debe tener este nombre para que Blender lo reconozca).

  3. Abra la sección Rutas de Archivos de las Preferencias.

  4. Configure la ruta del archivo Scripts para que apunte a su directorio de scripts (por ejemplo, my_scripts).

  5. Guarde las preferencias y reinicie Blender para que reconozca la nueva ubicación del complemento.

Ahora, cuando instale complementos, puede seleccionar Ruta de Destino al instalar scripts de terceros. Blender copiará los complementos recién instalados en el directorio seleccionado en sus Preferencias.

Bundle Dependencies#

For add-ons to be bundled as extensions, they must be self-contained. That means they must come with all its dependencies. In particular 3rd party Python modules.

They are a few options for this:

Bundle with Python Wheels.

This is the recommended way to bundle dependencies.

Bundle other add-ons together.

This is recommended if an add-on depends on another add-on.

Make sure that both the individual and the combined add-on check for already registered types (Operators, Panels, …). This avoids duplication of operators and panels on the interface if the add-ons are installed as a bundle and individually.

Bundle with Vendorize

This can be used as a way to bundle a pure Python dependencies as a sub-module.

This has the advantage of avoiding version conflicts although it requires some work to setup each package.

Legacy vs Extension Add-ons#

With the introduction of Extensions in Blender 4.2, the old way of creating add-ons is considered deprecated. While the changes are rather small they impact existing add-ons.

In order to allow a smooth transition process, the so-called legacy add-ons will continue to be supported by Blender. They can be installed via Install legacy Add-on button in the User Preferences.

All add-on maintainers are urged to convert the add-ons they want to share, so they are future proof and can support features like updating from the extensions platform.

Converting a Legacy Add-on into an Extension#

  1. Create a manifest file.

  2. Remove the bl_info information (this is now in the manifest).

  3. Replace all references to the module name to __package__.

  4. Make all module imports to use relative import.

  5. Use wheels to pack your external Python dependencies.

  6. Remember to test it thoroughly.

Nota

For testing it is import to install the extension from disk and check if everything is working well. This will get you as close to the final experience as possible.

Extensions and Namespace#

The legacy add-ons would use their module name to access the preferences. This could lead to a name clash when extensions with the same name (from different repositories) would be installed. To prevent this conflict, the repository name is now part of the namespace.

For example, now instead of kitsu the module name would be bl_ext.{repository_module_name}.kitsu instead.

This has a few implications for preferences and module imports.

User Preferences and __package__#

Add-ons can define their own preferences which use the package name as an identifier. This can be accessed using __package__.

This was already supported in the legacy add-ons, but not reinforced. As such this can break backward compatibility.

Before:

class KitsuPreferences(bpy.types.AddonPreferences):
    bl_idname = "kitsu"
    # ... snip ...

# Access with:
addon_prefs = bpy.context.preferences.addons["kitsu"]

Now:

class KitsuPreferences(bpy.types.AddonPreferences):
    bl_idname = __package__
    # ... snip ...

# Access with:
addon_prefs = bpy.context.preferences.addons[__package__]
Sub-packages

An add-on that defines sub-packages (sub-directories with their own __init__.py file) that needs to use this identifier will have to import the top-level package using a relative import.

from .. import __package__ as base_package

Then base_package can be used instead of __package__. The .. imports relative to the packages parent, sub-sub-packages must use ... and so on.

Nota

  • The value of __package__ will vary between systems so it should never be replaced with a literal string.

  • Extensions must not manipulate the value of __package__ as this may cause unexpected behavior or errors.

Relative Imports#

before:

from kitsu import utils

now:

from . import utils

Importing packages within the add-on module need to use relative paths. This is a standard Python feature and only applicable for add-ons that have multiple folders.

This was already supported in the legacy add-ons, but not reinforced. As such this can break backward compatibility.