Python

How to get vertices from Vertex Group by its name

To get a list of vertices from the vertex group by its name we can use the following code:

 

Fake-bpy-module

Code autocomplete greatly simplifies writing scripts or developing add-ons for Blender. One of the best autocomplete modules for today is developed by Nutti. Last updated 20190718.

The project is hosted on the author’s GitHub: https://github.com/nutti/fake-bpy-module

The modules are distributed via pip or as a pre-generated-modules. Author also provides a module generator with which you can assemble autocomplete modules yourself.

Decorators for node tree updation delay

When we create a field on the add-on interface panel, the value of which changes something in the node tree, each time the user changes the field value the node tree recompiles. If the user changes the value in that field by holding and moving the mouse, too frequent node tree recompilation will cause Blender to hangs.

This problem can be solved using decorators for deferred updating of the node tree.

Code by Skarn.

Class for creating nodes by type

Class for quick node creation by their type.

Code by Skarn.

How to protect your add-on from downloading through aggregators

With the Blender popularity growing, the number of add-ons created for it by third-party developers is growing too. A lot of high-quality professional add-ons are written for Blender now. Over time, the number of add-ons is becoming more and more. And on this wave aggregators appeared – programs and services independently searching for add-ons and allowing Blender users to install add-ons quickly, many at once, and bypassing add-on distribution channels selected by their authors. What caused a negative reaction of add-on developers.

How to detect if Local View is on in 3D View window

The following command returns the 3D View areas list with enabled Local View mode:

 

Changing objects visibility in the viewport and while rendering

The easiest way to hide and show rendering objects is to assign animation keys to them. To do this, move the cursor over the eye icon (visibility in the viewport) or camera (visibility when rendering) in the Outliner window, press the “i” key and then manage the created condition in the Graph Editor like the ordinary animation keys.

But this method is not always available. For example, we cannot assign visibility animation keys for collections, Blender will generate errors like:

“hide_viewport” property cannot be animated

or

“hide_render” property can not be animated

However, using the Blender Python API, we can control the visibility of such objects.