Working with Python in Blender can be hard. There are a lot (and I mean a lot) of extra code to write that I felt could be abstracted away. So I wrote a couple classes with a few helper methods to simplify this.
Please note that these probably will change and be extended as I learn more generative techniques etc. But I think it’s a good starting point for now.
Please note that this library only works in newer versions of Blender (3.4+ I believe) that contains Python 3.10+.
There are two main elements that you most commonly work with when programming generative art in Blender:
These are the two classes that this library is built around.
When starting a new generative project, there are stuff that I find myself doing over and over and over. Some examples:
Here’s an example of a basic setup.
# Example scene
scene = Scene()
scene.setup(
["cube", "sphere", "cone"], # object types to be deleted on script re-run
["toon"], # materials to be deleted on script re-run
"#EBEBEB" # world color
)
Working with objects / meshes in Python can also be difficult. That’s why I wrote the Object class. Some examples of what it can do:
Here’s a basic example of creating a cube of a certain size, position and rotation.
# Example object creation
obj = Obj(
"Cube", # object type
"toon", # material name
[1, 2.5, 2], # size x, y, z
[2, 2, 0, 0], # position x, y, z, z-extra (z + n)
[15, 12, 9]
)
This post is a work in progress. -insert examples here-