
Learn to automate Blender tasks with Python scripting and NumPy to build procedurally generated scenes, manipulate 3D coordinates, and combine section logic into a complete scenario.
Set up your working environment by clearing the scene, entering the scripting area, and using the four panels—the scenario, console, log, and editor—to write Python scripts and run them.
Execute code to add a cube in Blender using bpy, call bpy.ops.mesh.primitive_cube_add at location 0,0,0 with scale 1,1,1, and run the script to observe the cube at the origin.
use numpy with blender to import np, create a [0,1,2,3] array, loop through objects with bpy.data.objects.remove to clear scene, then place four cubes along the x axis with smaller size.
Use np.arange to create an array of values from 0 to 9 and arrange objects along the x axis in a Blender scene.
Use np.linspace to generate five evenly spaced values from 0 to 10 and distribute five objects along the x axis between (0,0,0) and (10,0,0).
Apply numpy's np.repeat to create an array of five elements all with the value 3. Execute and verify the result, noting the five elements positioned at [0,3,0].
Explore how NumPy creates arrays with multiple dimensions using the np.newaxis option, turning existing arrays into higher-dimensional structures and enabling data access inside a loop.
Learn to create 2d coordinate arrays by stacking x and y with np.hstack, using np.arange and np.repeat to position figures in a Blender scene.
Generate random z-axis coordinates using numpy's default_rng and random to build a multi-dimensional array with three columns, demonstrating how varying random values create disordered positions in Blender scenes.
Apply mathematical operations to arrays to adjust values, scaling the variable z by multiplying by 10. This produces random values between 0 and 10 and invites experimentation with different multipliers.
Generate a sine wave in numpy by applying sin to an array from linspace 0 to pi*2 with 10 points, illustrating procedural scene generation.
Create a terrain by building a square plane and generating vertex coordinates with NumPy. Assemble vertices, edges, and faces and add the plane to the scene collection using from_pydata.
Modify the z axis to create terrain slopes by summing base_z (from np.repeat) with random_z (random numbers divided by 2). Run the script to observe reliefs and variable terrain.
Use sin to shape a hilly terrain by computing NumPy sin values, iterating with a for loop, and adding their sum to z to form hills along the y axis.
Generate hills on the x axis by applying sin_z_x with np.sin of a selected period value from the instance to modify z, revealing hills on the x and y axes.
Explore how to shape procedurally generated hills by adjusting the sin-based period, increasing frequency to create multiple hills or decreasing it for extended hills.
Generate a forest in Blender using numpy and the beta distribution to place trees, tuning alpha and beta, with a size of 50 to widen the spread.
Set the forest width by assigning scale to 50 and multiplying by beta_random, then run the code to observe randomly distributed figures and beta distribution changes with a and b.
Center the figures in procedurally generated scenes by adjusting beta_random and subtracting half of size or scale; run the code to observe the centered result in the scene.
Generate a town by a parametric circle using sin and cos with t from 0 to 2 pi, compute coordinates with numpy and place houses along the circle.
Introduce a scale variable and multiply the x and y formulas by scale to enlarge the town; run the code and adjust size and scale to control house placement.
Change the town center location by introducing position_x and position_y, updating formula_x and formula_y, and observing how the town center shifts in the scene using these coordinates.
Import models from Blender files with bpy.data.libraries.load in a with block, copy and link the first object into a collection to insert pine tree, delete objects on run, view materials.
Use numpy to generate coordinates and create multiple instances in blender. The code uses linspace to create five positions between 0 and 10 and places each instance by updating obj.location.
Merge terrain and forest scripts into a single Blender Python workflow, rename duplicates to beta_a and beta_b, forest_size and forest_scale, then adjust the z-axis to place the forest above ground.
Copy the town generation code, rename variables to include [town], adjust the loop to place houses above the terrain by modifying the z axis, and run to view the scene.
Copy the import script to bring models from Blender files, replace the cube with the imported model and use loop coordinates, and set the file paths for trees and houses.
Position trees and houses on ground level using a shrinkwrap constraint in blender. Create add_shrinkwrap to attach objects to a target surface with a project axis set to negative z.
Create a lookAt function using mathutils vector operations to orient houses toward the town center, employing position, target, normalization, dot product, acos, cross product, and delta_rotation_euler for z-axis rotation.
Rotate each tree randomly by updating its z-axis delta_rotation_euler with random_direction and random.uniform from 0 to 2*pi, applied during tree insertion. Verify orientation in the scene with a clearer model.
Demonstrates generating random tree sizes by implementing increase_random_size to update obj.delta_scale with a random value on all axes during tree insertion, producing trees of different sizes.
Learn to create and apply a custom rgb material in Blender using a Python function, setting diffuse color, zero specular, and full roughness for a non-reflective terrain.
Learn to insert multiple models randomly by building arrays for trees and houses, randomly selecting among them during placement, and adjusting beta_a and beta_b to rearrange trees.
Modify the loop to apply a random offset to each house using obj_position, center_position, and direction, updating obj.location to produce a varied yet circular arrangement in Blender.
Learn to remove duplicate positions in procedurally generated scenes by applying np.unique in the loops that insert trees and houses, eliminating repeated elements in the array.
Create isNearObjects to prevent close object placement by measuring distances with the Pythagorean theorem, using a used_positions list to enforce a minimum distance when placing houses and trees.
Remove overlapping houses by adjusting town_t so the last location differs from first; divide pi*2 by town_size and multiply by town_size minus 1 to space houses along circle's full perimeter.
Export the procedurally generated scene to glTF 2.0 for use in another application, after tweaking parameters and terrain color, importing other models, and finalizing a scene you like.
Import a blender scene into Godot by exporting glb, save as a Godot file, enable ground collisions with a trimesh static body, and import the player model with keyboard controls.
Model a tree with Blender as part of the procedurally generated scenes course; follow the guide to create your own resources and save the finished model to a separate file.
Model a house using the course's resources, following this guide to create your own models, and save your finished work in a separate file from the code you write.
Hello and welcome.
If you are a designer or developer who is interested in creating scenes automatically with unique features and the ability to use them in an external application, this course is for you.
This course focuses on creating multiple Python scripts that will help us create a scene with a variety of elements in it.
For this, we will use Blender and its scripting section where we will use Python and the NumPy library.
With NumPy, we will use multiple of its function to generate multiple sequences of numbers that will help us to create 3D coordinates.
These coordinates will be used to create a terrain, a forest and a little town.
This course may be attractive to you because it can help you save time when you are designing scenes with the ability to add your custom elements to the script.
In addition, you will have access to the content created during the course.
I hope you find the content useful and that you can apply it to your personal projects.
Have fun and happy learning.
In this course you will learn:
How to Use NumPy to create coordinates in a 3D space.
How to procedurally generate a terrain with random features.
How to create a forest by using the beta distribution.
How to use a parametric formula to generate town.
Import external models.
Export the scene to use it in Godot.
You will require:
Blender 3.X.
Be familiar with Python or basic programing. You can follow the videos if you don't have any experience.
Optionally Godot to import the Blender scene.