Live stream set for 2025-06-28 at 14:00:00 Eastern
Ask questions in the live chat about any programming or lifestyle topic.
This livestream will be on YouTube or you can watch below.
Textured Triangle with Noise & Rotation Animation Using Blender Python
A Sample Project from “Mastering Blender Python API”
If you’re exploring the powerful world of Blender’s Python API, this tutorial offers a small yet visually engaging example that blends geometry creation, material scripting, and animation—all programmatically. This is a preview of one of the practical projects featured in my book “Mastering Blender Python API.”
Whether you’re a beginner or an intermediate user, this project shows how to:
- Create a custom triangle mesh
- Apply noise-based procedural textures to each face
- Animate a rotation to showcase all sides
Step 1: Create the Triangle Mesh
We’ll begin by using bpy
to create a simple triangle in the 3D viewport.
import bpy # Clear the scene bpy.ops.object.select_all(action='SELECT') bpy.ops.object.delete(use_global=False) # Create mesh and object mesh = bpy.data.meshes.new(name="TriangleMesh") obj = bpy.data.objects.new("Triangle", mesh) bpy.context.collection.objects.link(obj) # Define vertices and one triangular face verts = [(1, 0, 0), (-1, 0, 0), (0, 1, 0)] faces = [(0, 1, 2)] mesh.from_pydata(verts, [], faces) mesh.update()
Step 2: Apply Unique Noise Textures to Each Face
We’ll create materials programmatically and use Blender’s noise texture nodes for variety.
# Create and assign three materials with unique noise textures for i in range(3): mat = bpy.data.materials.new(name=f"NoiseMaterial_{i}") mat.use_nodes = True nodes = mat.node_tree.nodes links = mat.node_tree.links noise = nodes.new('ShaderNodeTexNoise') bsdf = nodes.get("Principled BSDF") links.new(noise.outputs['Color'], bsdf.inputs['Base Color']) obj.data.materials.append(mat) # Assign material to the triangle face obj.data.polygons[0].material_index = 0
This ensures the one face has a rich, randomized pattern. For more faces, you’d assign a unique material index per face.
Step 3: Animate Rotation to View All Sides
Now let’s spin the triangle to see all sides using keyframes:
from math import radians # Animate Z-axis rotation over 120 frames for frame in range(0, 121, 40): obj.rotation_euler[2] = radians(frame) obj.keyframe_insert(data_path="rotation_euler", index=2, frame=frame)
You can preview the animation with the timeline or render it as an MP4/GIF to showcase.
Screenshots and Screencast
Below are some visual results from the final Blender project:


About the Book: “Mastering Blender Python API”
This example is just a taste of what you’ll learn in “Mastering Blender Python API”—a comprehensive guide covering:
- Mesh generation
- Materials and shaders
- Node automation
- Rigging and animation
- Scripting best practices
📖 Click here to learn more or purchase the book
Need Help or a Custom Tutorial?
If you’d like personal help with Blender scripting or Python development, I offer private 1-on-1 tutorials and custom project guidance.
✉ Contact Me:
- Website: Ojambo
- Services Form: Ojambo Services
- YouTube DM: @ojamboshop