Tutorials

Automation in Blender: 8 ways to simplify repetitive tasks.

Often we want to perform an action to many objects in Blender. The most common way is to select all objects of interest, then ask Blender to manipulate them in some way.

In many cases Blender just does what we expect and that’s great. Other times there are simple (tho sometimes obscure) workflows built inside Blender. And finally, there are situations where we either have to manipulate each individual object by hand or … use Python scripting ( 😱 ).

Let’s go through each common situation one by one. We’ll start with the simplest. Around the end I’ll share a simple script I use all the time when Blender’s default tools fail me.

⚠️ Active Object vs Selected Objects

Before we go further tho, there is one thing that we must understand and that’s Blender’s idea of “Active Object” and “Selected Objects”. Experienced users can skip this section.

When we click on object we say that we “select” it. And that’s correct but also, we’re making it the Active Object. Only the properties of the Active Object are displayed in the Properties window. And certain operations are only performed on the Active Object, and NOT on all selected… at least not by default.

When we shift+click another object we add it to the group of selected objects and also make it the new Active Object. In the default Blender theme all selected objects are highlighted in dark orange, while the Active Object is bright orange.

There can be unlimited number of Selected Objects but the Active Object is always only one.

Blender, Active Object, Selected Objects

I’ll explain some uses of Active and Selected Objects in a minute. Let’s move on to the examples.

💠 When blender simply does its job

Quite a lot of operations are applied to the whole selection by default. Most commands under the Object menu will do just that.
(There are some exceptions as shown in the image).

Blender object actions menu

Moving, rotation, scaling, setting origin, applying transforms, setting key-frames etc. etc. These operations are applied on the whole selection as you’d expect.

💠 Copying properties from Active to Selected

Blender allows you set up some attributes for just one object, then copy them to many others.

An example of this is the CTRL+L menu (I’ve indicated the options I use often). It allows you to transfer data from the Active Object to all Selected ones. This is where Active vs Selected Objects becomes important.

Blender CTRL+L menu

Another example of this is the Copy Attributes Menu addon. It comes with Blender but is not activated by default, make sure you activate it.

Blender Copy Attributes Menu addon

When you do, pressing Ctrl+C in the 3d view will bring up a special menu with several options, all of which try to copy data from one object (the Active Object) to other objects (all Selected Objects)

💠 Telling blender to affect all selected (a.k.a. the ALT-key “trick”)

This is a slightly obscure Blender feature that many users don’t know about. It allows you to simultaneously change parameters on multiple objects.

This “trick” mostly applies to the attributes in the following tabs of the Properties Window. To be precise it mostly applies to the Object Properties and Object Data Properties which I have indicated with arrows.

Blender Properties Window

Again it’s important to keep in mind Active vs Selected Objects.

Let’s say you have multiple selected objects one of which is the Active one. Tweaking properties in the Properties window will normally only affect the Active object. However, if you hold ALT-key while tweaking a parameter it will (in many cases) affect the whole selection.
Let’s demonstrate that with examples.

In the following GIF I show 3 different ways to use the “ALT-key trick”. As you can see there are several ways to apply it. Each produces a slightly different result:
· hold ALT while dragging a Value parameter
· hold ALT while you click on the Value parameter, then enter a value, then press Enter
· click on the Value parameter, enter a value, then press ALT+Enter

Blender. Manipulate many objects with ALT key. GIF
click to enlarge

The above example is not extremely practical but it’s good for showing all variations of the technique. Here I something I actually use often: Setting up Auto Smooth for several objects.

Blender. Auto Smooth on many objects with ALT key. GIF
click to enlarge

This should give you an idea how to use the ALT key to tweak many objects at once. In general it can be applied to all Checkboxes and Value parameters that are shared between Objects. I encourage you to add a few spheres and monkeys to a scene and ALT+click around to see what happens.

However, there are many buttons and options in the Properties window where ALT+click does nothing!

Examples that don’t work with ALT

🔴 Adding/Removing Materials etc.

Anywhere you see the +/- signs for adding and removing Materials/Vertex Paint/Vertex Weight/UVs etc. will not work with ALT. However if there is a a little downward arrow below them, it may contain options that allow you to apply an action to many objects.

Add Remove Materials Vertex Paint, Vertex Weight, UVs

🔴 Clear Custom Split Normals

If you have worked with imported meshes in Blender you may know this little troublemaker. I honestly don’t know what it’s for, my only experience with it is trying to get rid of it (on many objects in some cases). ALT-clicking it will not affect all objects, just the Active one. 🙁

Clear Custom Split Normals

🔴 Modifiers and Constraints

You can’t add Modifiers or Constraints to many objects at the same time. However, you can copy them from the active to selected objects as explained above (using CTRL+L).

💠 Manual Work (aka “Don’t be lazy”)

Let’s face it. There will be times when you need to do an action to 653 objects.
Yet Blender doesn’t give you a good tool for the job.
There is no addon for it either.
You know there is a scriptable solution but you can’t figure it out.
If it’s a one-off task you can just do it by hand. Yeah, it’s going to be a boring 30 minutes, maybe an hour. But once it’s done you can move on with your work. That’s better than spending 5 hours googling a solution.

💠 Repeat Last Action (Shift+R)

Repeat Last Action, shortcut Shift+R can be very useful. It works with almost any command or operation you can think of.

Try it. Create a couple of objects. Select one and perform an action. E.g. add a Subdiv modifier, add or delete a Vertex Group, rotate or scale the object etc. etc.
Then select another object and press Shift+R. The same last action will be performed on the second object.

💠 Using Addons

There are a bunch of addons that can help with repetitive tasks. Here is a few I can think of. If you know other ones, write in the comments section. Pretty please! I really want to give them a try.

  • Batch Operations – a monster addon that I don’t actually use but it seems powerful.
  • Copy Attributes Menu addon: already mentioned above.
  • Commotion: has many functions but the one I’ve used a lot is Offset Animation, which can be applied to hundreds of objects. Useful in creating beautiful motion graphics.
  • Command Recorder Addon – you can think of it as “Repeat Last Action (Shift+R)” on steroids. Allows you to record a set of actions (or “macros” as they are called in other software) and then perform them again and again with a click of a button.

💠 Custom Scripts

This is why I started writing this article in the first place. I found out that with a few lines of Python script I can easily repeat almost any action or a set of actions to a group of objects.

This is what it looks like:

import bpy

sel = bpy.context.selected_objects

for obj in sel:
	bpy.context.view_layer.objects.active = obj
	#action to be performed on each selected

What the script does is create a list of all selected objects. Then it goes through the list. For each object, first it makes it the Active Object. Then it performs one or more actions on it. Then it moves to the next one and so on until the list is over.
Obviously you have to replace the last line with something useful.

Concrete Examples

🟢 Remove Custom Split Normals on all selected

The annoying Custom Split Normals I mentioned earlier. With 5 lines of code I can remove them from hundreds of objects if I need to.

import bpy

sel = bpy.context.selected_objects

for obj in sel:
	bpy.context.view_layer.objects.active = obj
	bpy.ops.mesh.customdata_custom_splitnormals_clear()

🟢 Give all Selected random Rotation and Scale

Slightly more complex example to show that you’re not limited to performing a single action.

I actually used this in practice recently. I wanted to drop a few hundred rigid bodies but I wanted each one to have a random initial rotation and scale.

(In this case setting the active object ( bpy.context.view_layer.objects.active = obj) is actually not necessary but it doesn’t hurt either so I left in there)

import bpy
import random #Python library for dealing with random numbers

sel = bpy.context.selected_objects

for obj in sel:
	bpy.context.view_layer.objects.active = obj
	random_scale = random.randint(50,100)/100
	obj.scale = (random_scale,random_scale,random_scale)
	random_rot_x = random.random()*360
	random_rot_y = random.random()*360
	random_rot_z = random.random()*360
	obj.rotation_euler = (random_rot_x, random_rot_y, random_rot_z)

So I use this all the time now. I copy and paste this Python snippet. The rest depends on finding out the right Python command I want to use.

There are a few simple steps I take when I look for a suitable Python code.
Here is a screenshot of my “Hacking” workspace and the general workflow.
1. Find out the command you need. Very often you’ll find it in a tooltip
2. Another way to find a Python command is is from the Info Window
3. Test the command in the Python Console
4. Write the actual script
5. Did you get the desired result. Yes? Great. No? Redo the above steps with different inputs.

If you don’t see tooltips, make sure your Interface is setup correctly:

Blender Preferences Tooltips

And of course if you’re stuck, there is the Python API Reference and Google.

Conclusion

I tried to convey the main methods for manipulating large amounts of objects in Blender. Obviously, I haven’t covered everything but I hope you learned something interesting. Know something interesting that I haven’t mentioned here? Let us know!

Creating brush alphas for Zbrush/Blender (+ FREE alphas giveaway)

In this tutorial I am going to show you how I created my lips alpha pack. So by the end you’ll know how to create high quality alphas (not just lips). I’ll also share FREE samples of my alphas and other resources so stick around to find out the details 🙂 .

zbrush, detailed lips final render
Result achieved with this technique.
click to enlarge

Process Overview

Here is an overview of the whole process so you know what to expect:

●Project photo details on 3d mesh
●use projected texture as displacement
●enhance projected details by painting in photoshop/gimp/krita/…
●further enhance details through manual sculpting in blender/zbrush/…
●bake out displacement map
●clean up displacement map to finalize your alpha

Making skin detail alphas based on photos is challenging because of all the specularity, sss, shadows etc. Manual work is hard to avoid. You’ve been warned! 🙂

I start with a simple model of the lips.
When creating some types of alphas you could just use a plane mesh. But with lips I think it’s nice to see something that resembles the final result. I created a UV layout that emphasizes the lips area. I’ll share this base model free in a second.

lips base model for alpha creation

click to enlarge

If you want to follow along here is a 3d model and reference images.

Download from Dropbox || Download from GDrive

Speaking of reference images… WHERE DO YOU GET GOOD REFERENCES FROM???
The easy thing to do is go to google image search and type in whatever you’re looking for. E.g. lips.
With all the editing we’ll do to the image I think almost any image would be OK to use. It’s always good to be on the safe side of the law tho. Luckily I found an amazing free resource with a very permissive license.
https://www.pexels.com/
I’ve include some really good lips images from that site in the package above.

I then project photo details on the lips.
The workflow I use is Blender’s Quick Edit in an external app. If you’re not sure what I am talking about here is a video that explains it well:

In zbrush you could use zapplink to do the same.
Alternatively you could use a stencil to project the details but I personally don’t like this workflow. Or if you’re old-school you could conform the photo reference to the UVs in photoshop/gimp. Whatever works for you.

When I am done projecting I apply the generated texture as displacement. That inevitably look like crap. 😢 💩 Not to worry, we’ll fix that pronto!

base lips model with projected texture
click to enlarge

The Modifier setup I use in blender looks like this:
-Multires, 6~7 subdivs or so (Multires, not Subdivision!)
-displacement modifier
This is will become important in a later step.

blender displacement + multires modifier

The next step is to try and “grade” your texture. The guys from Flipped Normals have an excellent tutorial on how to do that.

In fact this tutorial inspired me to make my own alphas. In some cases grading takes you a long way…
…with lips however I found it to be hit-and-miss. Sometimes it helps a bit, other times not so much.

Here is my result after grading. Still quite meh 💩 😀 As I said this process is not as helpful with lips and in this particular case it was almost pointless. But in other scenarios it’s priceless. I include it for the sake of completeness.

lips displacement after grading the texture
click to enlarge

From here the serious manual work begins. Yay!

● In photoshop I load the projected texture. I emphasize all wrinkles by drawing black lines wherever I perceive a wrinkle. I’d recommend splitting the lines/wrinkles in to primary and secondary. This gives you a nice
variation in detail.

zbrush lips alphas manual painting
click to enlarge

● keep the lines on separate layers. Then duplicate the layers a few times and blur each layer progressively.

This gives you a crisp wrinkle which gradually fades away. Basically this sort of V-profile:

●I emphasize the space between the wrinkles by painting light areas with a soft brush with low opacity. You can go heavy handed here. Or you can be precise if you want a specific detail.

After the manual painting in Photoshop I get this.

zbrush lips alphas after manual painting
Now we’re getting somewhere!
click to enlarge

Once the displacement starts to look decent I apply the Displacement modifier. That gives me a fully usable Multires mesh that I can work with in Blender. That’s why I said that the modifier setup (Multires + Displace) is important. This is a really powerful workflow in Blender.

Finally I sculpt the details some more by hand. For this step I often move to Zbrush but it can be done in Blender or whatever sculpting app you like. With this example I actually sculpted it in the new Blender 2.8. The new eevee viewport/workbench is a pleasure to sculpt in.

If I were to use zbrush I would export the displaced highest res mesh to zbrush and use “Reconstruct Subdivs” to get a proper subdivision mesh.

The brushes I use:
Blender: Crease (to emphasize wrinkles), Inflate (with a largish brush to emphasize areas between wrinkles), Sculpt/Draw(for specific details), Pinch (use sparingly)
Zbrush: DamStandard (to emphasize wrinkles), Inflat (with a largish brush to emphasize areas between wrinkles), Standard(for specific details), Pinch (use sparingly)

Nothing fancy.

This is my finished result.

zbrush lips alphas final
click to enlarge

Now that we have created really nice detail we need to bake the displacement. With that we’re almost done!
For this step I have developed a workflow in zbursh that I stick with.
I use MultiMap exporter plugin because it’s easy to work with. My Displacement Map setup looks like this.


Notice that Scale is set to 10. When you try to bake the map, zbrush will ask you if you really want to go with those settings. Say YES. The default setting of 1 produces displacement that is too weak our purposes (generating alphas). Sometimes I set Scale to 20 or higher. You have to play with the settings and see what works best.

I set the image resolution to 4k. That gives me enough resolution to create 1k or even 2k alpha maps afterwords.

I like working with 32 bit EXR images. They produce great results and I can convert them to other formats and bit depths if I need to.

Finally I take the displacement map and divide it up in chunks that can be used as alphas.

zbrush lips alphas split up
click to enlarge

I paste each piece into a new Photoshop document (32bit) filled with 50% gray. Then erase the edges of the pasted detail to avoid sharp edges in my alphas. The final result looks something like this:

final zbrush lips alpha

Note that if you work with 32 bit images as I recommend the detail in the image may be barely visible and thus hard to work with.
(The images in this tutorial have been tweaked for presentation purposes). To make them easier to work with, add a Levels Adjustment Layer and crush the values.

Remember to turn off the Adjustment Layer before you save out your final alpha.

DONE!
It’s an arduous process so if you stuck till the end, good job!

Finally you can grab the free alphas and resources here:

[gumroad id=”lipsfree” text=”FREE Alphas and Resources!” ]

If you are interested in the full version of my pack, check it out here. For 5 bucks you can save yourself all of the above work x5 times! 😛

[gumroad id=”zbrush_lips_alphas” text=”$5+ Purchase”]

If you have any comments or questions, share them below.

Before you go, if you know someone who’ll like this tutorial or the free alphas…why not share it with them?
Cheers and happy detailing!