Python

Mirroring an object with custom normals correctly

To mirror an object along X, Y or Z axis in Blender the “Miror” operator is usually used. For example, to mirror an object along the global X axis, in the 3D viewport window menu we need to select: Object – Miror – X Global. Or we can do it simpler just applying a scale of -1 to the object along the desired axis: s – x – -1. However, if there are custom normals on the object, they are not recalculated, which subsequently causes the appearance of various artifacts.

Enabling and disabling collections using the Blender Python API

We can enable and disable a collection from interaction with the scene by switching the checkbox located in the Outliner opposite the name of the desired collection. In order to do this using the Blender Python API, we need to access the collection through the View Layer of the scene on which the desired collection is located.

Getting a list of data from object properties using list comprehension

Most objects in Blender have multiple lists of data in their structure. For example, inside a “mesh” object there are list with vertices of this mesh, the list of mesh edges, and the list of mesh polygons. And in the structure of each mesh vertex there is, for example, a list with its coordinates along the X, Y and Z axes.