Blender and Python
Blender and Python
Python
Austin Godber
May 2021
DesertPy
First off, what does Blender do?
● 3D Modelling & Animation
● 2D Animation
● Visual Effects
● Video Editing
● Much more
Blender: 3D Modelling
● Edit any data the user interface can (Scenes, Meshes, Particles etc.).
● Modify user preferences, keymaps and themes.
● Run tools with own settings.
● Create user interface elements such as menus, headers and panels.
● Create new tools.
● Create interactive tools.
● Create new rendering engines that integrate with Blender.
● Subscribe to changes to data and it’s properties.
● Define new settings in existing Blender data.
● Draw in the 3D Viewport using Python.
Source: https://docs.blender.org/api/current/info_quickstart.html
Blender Python Tips
● Enable Developer Extras
● Enable Python Tooltips
○ Now you can see python function names in
many “On Hover” info boxes.
● Start Blender from Terminal if possible, so
you can see the python errors. YMMV.
● Use the latest blender (>2.9), download
from their site if needed.
● Use the scripting mode.
Use The Scripting Window
Render Window
Render Window
Python Console
Render Window
Python Console
Info Window
Demos
● Modeling
○ Source: https://www.youtube.com/watch?v=rHzf3Dku_cE
○ TODO
■ Add Material
■ Add Light
■ Add Camera
■ Render
● UI Component
○ Later Meeting
○ Source: https://www.youtube.com/watch?v=cyt0O7saU4Q
See Model Demo
Final Model Code
import bpy
from random import randint
bpy.ops.object.select_all( action='SELECT')
bpy.ops.object.delete( use_global =False)
number = 500