Scripts

Render a single frame for preview when rendering animation

When rendering animations in Blender, it’s often necessary to save one single frame for later use as a preview. Of course, we can do this manually, after finishing the animation rendering, switch to the desired frame and separately render it. However, with the Blender Python API, we can organize the automatic saving of the desired frame during the animation render.

Autocomplete for developing Blender add-ons in the Eclipse IDE

The Eclipse IDE, like PyCharm, and Visual Studio Code, is one of the most popular IDEs for development, including Blender add-ons development. To improve the convenience of developing Blender add-ons in the Eclipse IDE, we can add an autocomplete to it – the code completion for the Blender Python API.

By the Pavel Geraskin tips.

Operators for globally hiding objects in all project scenes

To hide an object in the 3D Viewport window for the current scene we use the “object.hide_view_set” operator, which calls when we clicking the icon with an “eye” in the outliner. However, to hide the object in the viewport for all scenes of the project at once (clicking on the icon with the “monitor” image) a special operator is not provided. We can make it ourselves.

 

Compiling a video from a sequence of frames using the FFmpeg codec

Rendering directly to a video file in Blender is not always useful. More often, a sequence (a set) of frames is received after render, which then, for example, after additional post-processing, must be assembled to the final video file.

We can compile a sequence of frames into a video with Blender itself, with the Visual Screen Editor (VSE). Or we can use third-party codecs, for example, FFmpeg.

Objects pointers brokes if undo/redo operation is used

In Blender 2.8x the undo/redo operation system (ctrl+z / ctrl+shift+z) has been completely rebuilt. One of the results of this API change is when the undo operation is performed, all objects in the scene are fully recreated – the current object is destroyed, and a completely new object is created instead. Pointers to the old objects (before the undo operation) now point to invalid objects that can no longer be used.

Global materials override for the Blender EEVEE render engine

Some times we need to make a render of the scene with the single material, for example, for clay or wireframe renders. Blender has the global materials override option for the Cycles render engine in the “View Layer Properties” – “Override” but not for the EEVEE render engine.

Quick materials override for the EEVEE rendering engine can be made with a small script, as shown in the following video:

Script and video by Vitaly Sokol.

Setting operator parameters features

When you make a button in a custom UI to call the operator with passing the necessary parameters to it, pay attention that only the parameters specified explicitly will be sent to the operator. Other operator parameters will remain with default values.

For example, we need to execute the “transform_apply” operator – applying object transformations with applying just the scale.

If we call the operator as follows:

But all transformation (scale, rotation, and position) will still be applied to the object.

How to check the direction of a Bezier curve

The direction of a Bezier curve, visually indicated by its normals slope, can be checked by the indices of its points.

The Bezier curve points indices always ascending in the curve direction.

So, having two points on the curve we can get the direction through their indices: