#StopRussianAggresion - support Ukraine!

Domino effect in Blender Python

Here's all the code you need to create the animation above:

import bpy
bpy.context.object.rigid_body.type = 'PASSIVE'
for i in range(025):
    bpy.ops.transform.resize(value=(1610), constraint_axis=(FalseTrueTrue))
    if i==0:

And here's how it works:

(If you're completely new to Blender Python, click here to find out how to copy-paste the code.)

Blender's physics engine is very powerful, but at the same time very easy to handle programatically. If you're learning Python, playing with physics is a great way to practice. For the domino effect, all we need is a plane and several blocks.

The plane, which will serve as a table on which the blocks stand [line 1], as well as the blocks are Rigid Bodies [2]. Once a Blender object is set as a Rigid Body, it behaves like, well, a rigid body, which means that other rigid bodies won't go through it, but rather push it away, bounce against it, etc. By default, Blender treats all objects as clouds or ghosts which do not interact when colliding. Turning them into Rigid Bodies is like changing them into stones and it's what gives them physical properties.

The plane is a "passive" [3] Rigid Body, which means gravity won't pull it down. The blocks are active.

A quick overview of the code:
[0] load the Blender Python module
[1-3] create the plane and set its physics
[5-7] create the domino blocks - they are simply flat rectangular prisms
[8] resize the blocks
[9-10] rotate the first block so that it falls down and starts the chain reaction

Try experimenting with different placement of the blocks - how about a sine curve or a circle?

Click here to download the .blend file which includes the code

More tutorials:

3d fractal in Blender Python

Domino effect (10 lines)

Wrecking ball effect (14 lines)

Fractals in Excel


Your first program in JavaScript: you need 5 minutes and a notepad

Animated fractal (32 lines)

Tutorial - interactive, animated sprites in JavaScript

8-bit style sine scroll (30 lines)

YinYang with a twist - 4 circles and 20 lines of code

Count the dots - optical illusion (18 lines)