How to check if Blender object property/attribute is read-only

To check is an attribute/property of any Blender object (mesh, node, modifier, etc.) read-only:

  1. With the is_property_readonly function, execute the following command:

<object> .is_property_readonly (‘<property name>’)

  1. Through the rna structure, execute the following command:

<object> .bl_rna.properties [‘<property name>’]. is_readonly

For example, for the “is_editmode” mesh property (is the mesh in edit mode or not):

How to get the version of the add-on installed in Blender

A complete list of add-ons installed in Blender we can get using the addon_utils:

Having the add-ons list, we can get the version of the desired add-on by its name with the following code:

Where the ADD-ON_NAME is the name of the desired add-on.

If the add-on is missing a version indication, the default result will be returned.

 

How to programmatically switch between vertex, edge and face selection mode

Change the mesh_select_mode property to switch in mesh edit mode between vertex, edge and polygon selection mode in Blender.

For vertex selection mode:

Edge selection mode:

And face selection mode:

The multi-select mode is enabled too. For example for vertex and face selection mode:

In BMesh for vertex, edge and face selection mode:

For multi-select in BMesh:

 

Learning loops

In general, the “loop” is usually a sequential selection of several points, edges or polygons of a mesh.

However, there is an element in the mesh structure, which is also called a “loop”. It is a combination of one vertex with one edge of the mesh. Let’s try to learn what these “loops” are for.

Continue reading “Learning loops”

How to pass command line arguments to a Blender python script or add-on

When starting Blender from the console it processes all parameters passed through the command line. However, some scripts and add-ons for proper work may require specifying their unique command line arguments. If you specify such additional parameters in the command line, Blender will also try to process them, which is likely to result in an error. Blender provides a special way to exclude such arguments from own processing.

Continue reading “How to pass command line arguments to a Blender python script or add-on”

Creating radio buttons in the Blender add-ons interface

State switches so-called “radio buttons” are used in the case to limit the choice by one value from several available ones. There are a lot of such buttons in the Blender interface, for example, switching between RGB and BW rendering modes or setting the texture mapping mode. Such buttons can be created in the Blender add-ons interface too.

Let’s create our own radio button switcher.

Continue reading “Creating radio buttons in the Blender add-ons interface”

How to programmatically check if the operator is registered in Blender API

Single add-on or script can contain several different operators, and not all of them may be registered in the API by the register() function. To verify that the required operator is registered in the Blender API, run the following command:

Where:

_operator_bl_idname_ – the text value of the bl_idname operator property.

For example for an operator:

the command will look like this:

 

How to programmatically check if the Blender add-on is registered

To start working every Blender add-on must be registered by setting up the checkbox before add-on name in the User Preferences window – Add-ons page.

To programmatically find out if the required add-on is registered, run the following command:

Where:

add-on_name – the name of the add-on file (without the .py extension) or the name of the add-on package, if it was installed from the package.

Debugging multifile Blender add-on by quick reinstall

It is convenient to use the following system for debugging developing multi-file Blender add-ons. But it has one drawback: modules imported in __init__.py file becomes available only after the file running (after the execution of the register() function). This means that any access to the imported modules before they are registered will cause an error. This is not critical in most cases, but it will cause a problem if, for example, in one imported module is used inheritance from the class, described in the other imported module, because the classes descriptions are processed before the add-on registration.

To get more freedom working with imported modules, we can use another way to debug the add-on – do not run the add-on directly from the development directory, but install it in Blender and check its “live” work. However, manual add-on reinstallation requires a set of routine actions, which complicates such sort of debugging. This issue can be solved by reinstalling the add-on in automatic mode.

Continue reading “Debugging multifile Blender add-on by quick reinstall”

How to install and uninstall Blender add-on via python API

Blender add-ons installation and uninstallation can be managed through the python API. Use the following commands in a script:

To deactivate the add-on:

To uninstall the add-on:

Continue reading “How to install and uninstall Blender add-on via python API”

Mesh Custom Properties editing through the Blender API

New mesh Custom Property can be created through the Blender python API by executing the following code:

with:

  • object_name – name of the mesh
  • property_name – new custom property name
  • property_value – value of this new property

After executing this command, the new property will be created and will be available in the Properties window – Object panel – Custom Properties sub-panel.

Like any object custom properties, the created property has a number of parameters that can be accessed by clicking the Edit button. These parameters can also be changed through the API.

Continue reading “Mesh Custom Properties editing through the Blender API”

Working with UV-Maps through the Blender API

Active (selected) UV-Map:

Access to the active UV-Map by its name:

Continue reading “Working with UV-Maps through the Blender API”

Creating pop-up panels with user UI in Blender add-on

In addition to common panels (N/T/Properties) and their sub-panels, to display the user interface elements while developing Blender add-ons you can also use pop-up panels appearing on the screen when a user presses a certain key combination or perform any action. The simplest example of such panels is the panel that appears when the f6 key is pressed immediately after adding an object (shift+a) to the scene.

Blender API provides developers the ability to create such panels for their add-ons. Let’s consider the creating of a pop-up panel as an example of the “Message box” window.

Continue reading “Creating pop-up panels with user UI in Blender add-on”

BIS v.1.0.0 – Release

BIS (Blender Interplanety Storage) add-on release.

Finally, I finished it. It’s release now!

Download

Continue reading “BIS v.1.0.0 – Release”

BIS add-on v.0.0.3

BIS (Blender Interplanety Storage) add-on intermediate update to v.0.0.3

The addon is almost in the prerelease state.

  • All Cycles nodes are supported, including script and nested groups.
  • Also added the ability to save scripts/texts from the Text Editor.

To make a release, it was left to clean up a bit the server (site) side – increase the previews size, add tags and node names editing, make a separate list for saved texts. And also test the add-on with complex materials.

Download

Active objects access

How to access the active (selected) objects through the Blender Python API from scripts/add-ons:

  1. The active window (in which current action occurs):

  1. The active scene:

  1. The active (selected) mesh:

  1. The active (selected) material node (in the NODE_EDITOR window):

  1. The active (selected) material node (in the COMPOSITING window):

  1. The current text in TEXT_EDITOR window:

  1. The active (selected) UV-Map:

Continue reading “Active objects access”

BIS – Online Blender material storage

Blender Interplanety Storage (BIS) – the online material (shader) storage add-on for Blender 3D creation. With the BIS add-on, you can save materials (groups of nodes) to the online personal library and then convenient search and upload them. Saved materials are available from any computer through the add-on installed in Blender.

Download

The add-on is open source. If you want to donate – you can buy the add-on for a convenient price, or set the price to 0 and download it for free.

Continue reading “BIS – Online Blender material storage”

Working with MySQL database from Blender

Storing data in a remote database has become common practice in the development of software products. Blender is no exception. Writing scripts and add-ons, the developer may need to access the database to retrieve from it or write to it the necessary information. MySQL today is one of the most common and widely available databases and is well suited for working with Blender.

The interaction between Blender and MySQL database through the Blender Python API is not difficult, but it needs some preparation before stating:

Continue reading “Working with MySQL database from Blender”

Binding to timeline frames

Sometimes when creating an animation it is necessary to perform some actions according to the timeline or, the same, to the current animation frame number. Binding animation to timeline frames in Blender is possible using the built-in Python API.

As an example, let’s make a simple animation which turns one of the letters of any text from lowercase to uppercase in series.

Continue reading “Binding to timeline frames”

PartitionRender add-on v.0.0.5

Add-on PartitionRender v.0.0.5 update.

  • Added “SaveMultilayer” checkbox

If the checkbox is on – temporary render results saved in OpenEXR Multilayer format including all layers and passes for future use. Only finished image compiles automatically, different passes need to compile manually.

PartitonRender v.0.05
Download