Python tools in Blender

The Scripting layout

Blender has a handy “Scripting” layout ready for you, with

In the Menu, Help > Python API Reference will open a browser window pointing to the Blender Python API documentation. You want to keep this open at all time when scripting.

Accessing data

Some examples of how to navigate in Blender data from the console.

# With the default scene when starting Blender
 
for objects in bpy.data.objects:
    print(objects.name)    
# Camera
# Cube
# Lamp
 
for object in bpy.data.objects:
    print(object.location)    
# <Vector (7.9362, -7.1326, 3.8174)>
# <Vector (0.0000, 0.0000, 0.0000)>
# <Vector (4.0762, 1.0055, 5.9039)>
 
for object in bpy.data.objects:
    print(object.location.x)    
# 7.93615198135376
# 0.0
# 4.076245307922363