4.5

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.

Building a color cube in Blender

In the RGB color model, any color is represented as a combination of three basic colors: R – red, B – blue, and G – green. Basic colors are specified by a number in the range from 0 to 255. Therefore, any color in this model will be represented by a combination of three such numbers. For example, light orange will be represented by a set of numbers (255, 153, 51). The RGB model can be visualized by imagining it as a cube with a side equal to 255, all of whose internal points are vectors, the position of which is determined by a triple of numbers that determines the color itself.