How to pass command line arguments to a Blender python script or add-on

When starting Blender from the console it processes all parameters passed through the command line. However, some scripts and add-ons for proper work may require specifying their unique command line arguments. If you specify such additional parameters in the command line, Blender will also try to process them, which is likely to result in an error. Blender provides a special way to exclude such arguments from own processing.

Continue reading “How to pass command line arguments to a Blender python script or add-on”

How to render an object with reflections on a white background

The single object visualization most often is performed on a clear white background. It is difficult to achieve this through the common configuring the scene – increasing the illumination of the scene “lights up” the object, decreasing – the background becomes gray instead of white. If the object itself can be simply rendered on a transparent background and then imposed on white, but what about its reflections?

Let’s consider the way how we can render the object and its reflection on a white background.

Continue reading “How to render an object with reflections on a white background”

Debugging multifile Blender add-on by quick reinstall

It is convenient to use the following system for debugging developing multi-file Blender add-ons. But it has one drawback: modules imported in __init__.py file becomes available only after the file running (after the execution of the register() function). This means that any access to the imported modules before they are registered will cause an error. This is not critical in most cases, but it will cause a problem if, for example, in one imported module is used inheritance from the class, described in the other imported module, because the classes descriptions are processed before the add-on registration.

To get more freedom working with imported modules, we can use another way to debug the add-on – do not run the add-on directly from the development directory, but install it in Blender and check its “live” work. However, manual add-on reinstallation requires a set of routine actions, which complicates such sort of debugging. This issue can be solved by reinstalling the add-on in automatic mode.

Continue reading “Debugging multifile Blender add-on by quick reinstall”

Working with UV-Maps through the Blender API

Active (selected) UV-Map:

Access to the active UV-Map by its name:

Continue reading “Working with UV-Maps through the Blender API”

Rotating texture by nodes

In order to achieve the desired texture mapping on the object surface, we need a convenient tool for manipulating the texture coordinates. Especially for procedural textures mapped to the object without using UV-s.

The “Mapping” node combines tools for texture moving, rotating and scaling is suitable for most of the texturing tasks. But sometimes its power is not enough. Its major drawback is that it allows setting adjustment values only in certain fields within the node body. These fields have no inputs and cannot be connected to the other nodes.

However, we can implement the required functionality devoid of the “Mapping” node lack with the help of some other nodes. Let’s consider how to build a node tree to rotate the texture around the Z-axis of the object by a random value.

Continue reading “Rotating texture by nodes”

Creating pop-up panels with user UI in Blender add-on

In addition to common panels (N/T/Properties) and their sub-panels, to display the user interface elements while developing Blender add-ons you can also use pop-up panels appearing on the screen when a user presses a certain key combination or perform any action. The simplest example of such panels is the panel that appears when the f6 key is pressed immediately after adding an object (shift+a) to the scene.

Blender API provides developers the ability to create such panels for their add-ons. Let’s consider the creating of a pop-up panel as an example of the “Message box” window.

Continue reading “Creating pop-up panels with user UI in Blender add-on”

Modeling with curves: wires and pipes

Creating thin long objects like pipes and wires is the often task in the interior, scientific of fantastic scenes. One of the easiest and most convenient ways to create such objects is using curves.

The main curves advantage is the easiest control and editing: any time you can change the shape of the curve, move its points, add new and delete unnecessary ones. You do not have to work with a lot of mesh points, but only with several points of the curve, which is much more convenient. Preprocessing for rendering scene with curves is also performed faster than with meshes.

Continue reading “Modeling with curves: wires and pipes”

Installing Blender on Linux Debian server

One of the amazing Blender features is that the graphical user interface GUI is not absolutely necessary for its work. You can install Blender on an operating system without a graphical shell and successfully render your scenes. Such types of a Blender installations are usually required to organize various render farms.

For example, consider Blender installation on the server Linux Debian operating system.

Continue reading “Installing Blender on Linux Debian server”

How to render object with shadows on a transparent background

Sometimes it is necessary to create a render of an object with shadows on a transparent background. This occurs when you need to realistically embed a 3D into the photo or when creating an image to use it as a sprite in a computer game.

There is no special shader in Blender, like “Shadow catcher” in 3D Studio Max, which remains transparent display shadows. However, it is possible to achieve the desired result.

Let’s consider how we can get a shadow render on a transparent background using Blender:

Continue reading “How to render object with shadows on a transparent background”

Fighting with gradient aliasing when saving image as JPG

Background with simple gradient can greatly improve the final image. For example, a heart with gradient background looks like significantly better than the same heart with white background.

However, if you need to save such image as JPG, the gradient becomes aliased that fails the impression of the image. That problem is named “banding”. Is it possible to defeat the gradient aliasing?

Continue reading “Fighting with gradient aliasing when saving image as JPG”

How to copy a single modifier to multiple objects

Sometimes it is necessary to add a single modifier to each part of some complex object. The easiest way is to cycle part by part through all the object and add the desired modifier to each its part manually. But if the object consists of many parts, it will take a lot of time.

There are some ways to greatly facilitate this work:

Continue reading “How to copy a single modifier to multiple objects”

Are you still starting with the default cube?

Think for a moment – how many real scenes you created really with using that default cube?

Removing the default cube

Not much, right? But all the same, each time starting a clear scene, you press: x – delete. Again. And again. Let’s put on white magician gloves and once for all escape this nonsensical action:

Continue reading “Are you still starting with the default cube?”

Combining color and clay renders

For an effective portfolio demonstration, there is a good practice to show together with the color render the clay render to emphasize scene volume, lighting, models topology, as well as, in the case of photo-realistic rendering, showing scene “3D-essence”. The overlaying of these two renders in the same image could be an even more spectacular trick.

Overlayed render

Continue reading “Combining color and clay renders”

PartitionRender add-on

Blender add-on allowing to interrupt the rendering process and resume it from the interrupted place. For those who are not able to have the powered-on computer for render for a long time.

For example, the whole image render takes 12 hours. And there is no way to have the computer powered on all the time, but it is possible to power it on for 5 hours with breaks. If you interrupt the standard rendering process to turn off the computer – next time render starts from the beginning, and all progress is lost. PartitionRender add-on allows dividing the image into several blocks – partitions, each of them is rendered separately. Choosing division by X and Y in 2 parts, the image is divided into 4 blocks. Each of them will be rendered about 3 hours that fit in the time to work. Each partition after rendering saves to file. The next time (after rebooting the computer) PartitionRender automatically continues with the partition on which the break occurred. After finishing all partitions renders, partitions automatically compile to the whole image in compositing.

Download

Add-on is a free and open source. If you want to support it – you can buy the add-on for a convenient price, or set the price to 0 to download it for free.

Continue reading “PartitionRender add-on”

Blender add-ons development code reuse with symbolic links

In the development of add-ons, their modules should be abstracted as much as possible. For a very simple reason – functional, created for a current add-on, will likely need in the next add-on, and possibly not even in one. In the add-on release, the problem of accessing to such common functionality modules is easily solved – all the necessary modules are included in a single package and distributed together. However, during the add-ons development, such modules are much easier to store separately, in one instance, without associating them with any particular package, and import if necessary the desired modules to the desired add-on.

Using symbolic links in the add-ons development
Using symbolic links in the add-ons development

In accordance with the packages import rules, Python allows to refer modules in the following ways:

Continue reading “Blender add-ons development code reuse with symbolic links”

Creating multifile add-on for Blender

In the development of complex add-ons with large code volume storing all the code in a single file is inappropriate. When a single file contains logically unrelated classes, functions, and datasets, it is difficult to read, debug, find the necessary code pieces, reuse code. Such code layout is considered as very bad programming tone.

Blender Python supports modular system that allows subdividing logical code parts of the add-on into different files, and then connect them to use. Even if you have never thought about modules, creating scripts or add-ons, you have already used them – any code stored in the *.py file is a separate independent module. Just your addon consists of only one module. Complex add-ons may consist of several tens of modules.

Multifile add-on
Multifile add-on

Continue reading “Creating multifile add-on for Blender”

How to check errors if Blender closes together with system console window

Sometimes when debugging scripts or add-ons, errors not only interrupt the code execution but also causes the complete closure of Blender together with its system console. This case its impossible to check errors and view errors messages.

To find a failure, Blender can be started from the command line interpreter cmd. In this case, Blender output log is redirected to the cmd window which, when the program falls due to errors, not closed. If Blender closes all error messages stay available to check in the cmd window.

Running Blender from command line interpreter cmd
Running Blender from command line interpreter cmd

To start Blender from a command line interpreter:

  1. Start the interpreter ( “Start” – Run – cmd)
  2. In the cmd window type the full path to the installed Blender. For example: C:\”Program Files”\blender-2.78a-windows64\blender.exe

Part of the way contains spaces must be enclosed in double quotes – like “Programm Files” in this example.

In search of ideal sphere

We create spherical surfaces often in the modeling workflow. It would seem that the sphere is the simplest object to model and any three-dimension editors, including the Blender, provides a default sphere in a set of basic primitives – just add it to the scene. However, is it really so easy to create a beautiful sphere?

8
8

Continue reading “In search of ideal sphere”

Creating panels for placing Blender add-ons user interface (UI)

One of the essential conditions of comfortable work is the convenience and speed of accessing add-ons functional. It is not enough to write add-on and register it in Blender API system. Be sure to give the easily call add-on functions ability to user. So, any addon should determine a place to put interface buttons that provide access to its functionality.

All available Blender user interface located on panels. Three panels are the most used: T-bar – opens/hides by pressing the t keyboard button, N-bar – opens/hides by pressing the n button, and the Properties panel – called in the main menu of any window typed it as Properties.

Blender API allows to define users panels to place add-on functional buttons on any of this three main panels.

Continue reading “Creating panels for placing Blender add-ons user interface (UI)”

Creating Blender add-on

Blender scripting system provides lots of opportunities to simplify and accelerate the workflow, allowing to outsource routine operations to the system and expanding work opportunities through access to the scripting language. However, writing a good script which can be used frequently in various projects, uncomfortable each time to reconnect it to each new project. In addition, this script can be improved with some windows and editable parameters fields. Making complete add-on from the script, you can expand it with additional functionality and connect to the Blender add-ons system.

User-created Blender add-on
User-created Blender add-on

Continue reading “Creating Blender add-on”

Using external IDE PyCharm for writing Blender scripts

Blender has an internal text editor to write scripts on Python language. However, this editor is much inferior to specially designed for writing code IDEs. There is no satisfactory autocomplete, comfortable syntax lighting, possibility to organize projects in Blender internal text editor – all those things that determine the speed and ease of code writing. However, it is not difficult to connect and use an external IDE for writing Blender scripts.

External IDE for scripting in Blender
External IDE for scripting in Blender

Continue reading “Using external IDE PyCharm for writing Blender scripts”

Creating screws

To create screws in Blender the easiest way is to use plugin, like Bolt Factory, which comes in standart complectation. But the plugin features are not always enough, and the result of using Subdivision Surface modifier on the screw created by plugin is not very beautiful. However, it is not difficult to create screw manually.

Screws
Screws

Lets create high poly screw suitable to render in any major plans.

Continue reading “Creating screws”

Filling volume with items

Some times during the modelling process the problem of filling some volume with number of items occurs. For example it may be a jar with coffee grains, sugar bowl with pieces of sugar, bag of jewels, box with screws and nuts, a bowl of candy, and many others.

Jar filled with items
Jar filled with items

All this can be made manually. Creating some copys of items and filling voulume with arranging them in a random order. However this approach much time and efforts to control that the items do not overlap with each other and with the walls of the filled object. To simplify our work we can use the Rigid Body tool – solid-state simulation in Blender.

Continue reading “Filling volume with items”

Using drivers with nodes

There is one moment in node tree, created to separate the sides of the planet model by “day” and “night” – when the position of light source changes its new coordinates every time needs to re-specify manually in Value nodes. It is very inconvenient while setting the scene. To eliminate this fault Blender “drivers” system can be used.

Using drivers in node system
Using drivers in node system

Continue reading “Using drivers with nodes”