The classic Blender Guru tutorial but entirely in a python script.
This is the creation of a juicy, overflowing donut 🍩 in the classic blender tutorial manner. The big difference is here it is made entirely by script rather than by mouse or by tablet.
Why? Why not? But also - shouldn't we be able to treat blender models and environments the same way we treat our code - by saving it in stages and states in git?
If you can script it, script it.
import bpy
from math import *
Import the blender python package and math because it always comes up.
First we set the donut 🍩 settings to initial state. A fat donut 🍩 as Blender Guru states:
bpy.ops.mesh.primitive_torus_add(major_segments=40,minor_segments=16,major_radius=0.91,minor_radius=0.61)
- Major Segments, Number of segments for the main ring of the torus 🐂
- Minor Segments, Number of segments for the minor ring of the torus 🐂
- Major Radius, Radius from the origin to the center of the cross sections
- Minor Radius, Radius of the torus’ cross section
Next we need to select the object to begin working with it so we have donut!!!!
donut = bpy.context.active_object
bpy.ops.transform.resize(value=(0.033,0.033,0.033))
bpy.ops.object.transform_apply(scale=True)
bpy.ops.object.shade_smooth()
The full list of Object Modifier Type Items -> here
bpy.ops.object.modifier_add(type='SUBSURF')