Python

Simplifying animation curves in Blender

There are cases, especially when importing from third-party packages, where animation curves in Blender become literally cluttered with numerous control points, most of which have little effect on the overall shape of the curve. Many points on a curve increases the complexity of the scene and complicates animation calculations. However, the number of points on animation curves can be easily reduced if necessary.

Switching the camera to walk/fly mode in Blender

Adjusting the camera position in Blender the usual way isn’t always convenient, especially in large, open scenes. For this reason, Blender offers the ability to switch the camera to “walk” or “fly” mode. In these modes, we can control the camera as if you were playing a first-person video game. The camera is moved using the arrow keys or the WASD keys familiar to computer gamers.

Quickly showing/hiding gizmos in Blender

Whether to use gizmos when working in Blender is a highly debated topic among 3D artists. However, even without using gizmos on a regular basis, there are times when “those arrows” could be very useful. If gizmos are hide by default in our Blender settings, we can write a simple script that will temporarily show and hide gizmos in the 3D viewport.

Moving origin to selection – wrapping to an add-on

Last time, we wrote a small script to quickly move an object’s origin to the center of a selection. Now, we can perform this operation quickly, but we need to keep an additional area open with the script text. To avoid this inconvenience, we can turn our script into an add-on and assign it to a convenient key bind.

Moving origin to selection in Blender

Moving the center point of a mesh (the origin) to the current selection is one of the routine operations when modeling in Blender. However, there’s no base operator for this in Blender, and it usually has to be performed in several steps: moving the 3D cursor to the center of the selection, moving the origin to the 3D cursor, and then, if necessary, returning the 3D cursor to its original position. All these operations can be combined in a simple script and performed in a single click.

Converting a Mesh to a Bezier Curve

To convert any flat mesh to a Bezier curve, we need to perform several operations: first, convert the mesh to a curve, then convert its points to Bezier format (with “handles”), and, optionally, recalculate the number of control points to remove points that don’t affect the curves shape. All of this can be done in a single-click with the help of a simple script.

Enabling ghost environment mode in Blender

When working with a mesh surrounded by other objects in a Blender scene, we often need to ensure that all other objects don’t obscure it and interfere with precise modeling. In this case, the easiest way is to enable object isolation mode (pressing the “/” key), which hides everything surrounding the object from the screen. However, sometimes we need to simultaneously work with the mesh and control and relate it to its surroundings. In these cases, the “ghost” mode is best suited—when all surrounding objects appear translucent and don’t interfere with our work, but still allow us to perceive and control the scale and position of the object in the scene.

Making objects dynamic properties more controllable

We can assign additional custom properties to objects in Blender using the Blender Python API. Custom properties can be assigned to objects in the common way, using the “bpy.props” class objects, or by simply assigning the desired property to the object. However, while the first method immediately provides a set of controls for managing the property, such as maximum and minimum value constraints, default values, etc., the second method has no such defaults for the assigned property.