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.
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.
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 »
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 »
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 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
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 »
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 »
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 »
You may need to get a list of coordinates of the mesh’s UV, for example, when exporting a mesh from Blender’s internal format to any external formats.
A list of the mesh UV-s can be got by accessing the “uv_layers” structure:
1 2 3 |
bpy.context.object.data.uv_layers[:] # [bpy.data.meshes['Cube'].uv_layers["UVMap"], bpy.data.meshes['Cube'].uv_layers["UVMap.001"]] |
To completely remove the object from the scene through the Blender Python API do the following:
Open the “Text Editor” window.
How to delete object from scene through the Blender Python APIRead More »