Adding new items to the context menu
In Blender, we can add custom items to any context menu, called by pressing the right mouse button, to quickly execute the necessary operators.
In Blender, we can add custom items to any context menu, called by pressing the right mouse button, to quickly execute the necessary operators.
In order to append the necessary meshes into the scene by name from an external blend file, we can use the wm.append operator or use the BlendDataLibraries mechanism.
Appending objects into the scene by name from an external blend fileRead More »
To select all objects in a collection with the Blender Python API, we need to walk through the list of these objects and call the “select_set” method for each of them, specifying the “True” value in the parameter.
It is impossible to track the switching between object and edit mode by the user with common handlers in Blender, there are no handlers for such event type in the bpy.app.handlers. However, this can be tracked through the Message Bus.
Tracking when the user switching between object and edit modeRead More »
foreach_set is a convenient wrapper in the Blender Python API for quickly setting the desired value for each element of the bpy_prop_collection type. However, when using this function, script developers sometimes run into an error.
When writing add-ons for Blender, it is important to place UI elements – buttons, fields, switches, etc., so that the user can easily find them and have convenient access to them. Blender provides to add-on developers the following areas to place their custom UI:
In the Blender Python API, a collection does not have a direct pointer to its parent collection. However, we can get the parent collection by searching through the list of children of each collection in the scene until we find the current one.
When creating custom properties, the values of which the user can choose from a list, it is often necessary to filter the list of values offered for selection. We can use the poll function to shorten the proposed list of values by removing unwanted elements.
Filtering values available for selection through the UILayout.prop()Read More »
When executing modal operators such as rotation, translation, or scale, text with the current values of the mesh parameters being changed is displayed in the header of the current area. If necessary, we can display any required text in the area header.
We can’t set a collection active through the Blender Python API in one step. The “bpy.context.collection” property is read-only, and the “bpy.context.view_layer.active_layer_collection” has a “LayerCollection” type that cannot be set with the standard “Collection” type. To assign an active collection, we need to find the View Layer collection from the desired base collection and already set it as active.