I started to use Blender for one of my work for client. There're times when I need to modify, fix, re-create UV, map mesh to texture, etc by myself without waiting for artist to do that.

As for automation that we can achieve it in iOS workflow via Fastlane especially in automated testing/building, I'm slightly surprised to see that it has potential to be done in Blender as well.

Scripting in Blender

Above is the result I got from executing python script right inside Blender to automatically create a new cube, rename its name, and move its location.

Technically you can execute python script with Blender's GUI but Blender still runs in the background. Anyway I don't do it in this article.

Let's Get Started

Firstly remove a cube as shown on 3D View window, then you choose a screen layout by clicking on Choose Screen Layout button then select Scripting as seen below.

Choose Screen Layout

To have such UI element shows up, you need to select the panel as Info first as seen below.

Panel Type

Now you will get layout ready to script in python.

Enter code I shared on gist, or copy the following code to editor.

import bpy

def strVector3( v3 ):
    return str(v3.x) + "," + str(v3.y) + "," + str(v3.z)

# create a new cube

# newly created cube will be automatically selected
cube = bpy.context.selected_objects[0]
# change name
cube.name = "MyLittleCube"

# change its location
cube.location = (0.0, 5.0, 0.0)

# done
print("Done creating MyCube at position " + strVector3(cube.location) + " with name " + cube.name)

Then name the file to blender_cube_creation.py. Finally, click on Run Script.

Name and run script

Then you will see that Blender will create a new cube, select it, rename into "MyLittleCube", and translate to (0.0, 5.0, 0.0).


  • If you hold mouse over each Blender's UI element for a while, it will show a tool tip of python function that you can use it in the script.
  • Play around with each function in Python Console window at the bottom before combining them up in full script.
  • To know how to do something in code for certain actions we did directly on Blender GUI, just do some actions on Blender first, then look at Info window (on the top), you will see something like this for history of python functions called. Then you know which functions to call in python code.

Blender Info Window with History
Click on image to enlarge