Python
BPY plus
BPY plus – a set of modules to extend the Blender Python API. This is an Open Source project based on Blender API. It extends it with several new features and makes using some of the “bpy” functions easier.
Removing collections through the Blender Python API
We can delete collections in Blender through the “collections” list in “bpy.data”.
To remove a collection we need to use the “remove” method from the collections list, specifying the collection to be removed in the parameter:
Removing collections through the Blender Python APIRead More »
How to add a constraint to the object with Blender Python API
We can assign constraints to objects through the object “constraints” property.
To add a constraint to the currently active object, we need to create a new constraint in the object’s “constraints” list, specifying its type in the parameters:
How to add a constraint to the object with Blender Python APIRead More »
Another way to add code autocomplete when developing Blender add-ons in Visual Studio Code
To improve the speed and convenience of developing Blender add-ons with Microsoft Visual Studio Code, this IDE can show the code auto-completion for common Blender API types.
This way of adding autocomplete is by Zen3515.
Blender 2.91 autocomplete
Blender Python API autocomplete modules: fake-bpy-modules by Nutti update – added branch for Blender 2.91.
Last release: 2020.12.16.
Author GitHub: https://github.com/nutti/fake-bpy-module
Only files (without pip installation) https://github.com/Korchy/blender_autocomplete
How to get camera FOV in degrees from focal length in mm
The camera angle in Blender can be set both in millimeters – the Focal Length parameter, and in degrees – the Field of View parameter.
To get the Field of View in degrees from the Focal Length value in millimeters, we can use the following formula:
How to get camera FOV in degrees from focal length in mmRead More »
How to create a Vertex Group and add vertices to it with the Blender Python API
We can access vertex groups for the active mesh through its “vertex_groups” structure.
1 |
bpy.context.active_object.vertex_groups |
How to create a Vertex Group and add vertices to it with the Blender Python APIRead More »
How to create a new mesh UV with the Blender Python API
To make a new UV with the Python API and set coordinates to its points, we need:
First – create a new UV with the desired name:
1 |
new_uv = bpy.context.active_object.data.uv_layers.new(name='NewUV') |
Next, to specify the coordinates of its points, we need to cycle through all the “loops” of the mesh:
How to create a new mesh UV with the Blender Python APIRead More »