So you want to use Python to do stuff in Blender? Here are my notes as I go down the rabbit hole.
In Blender, Python is a tool for automating stuff you could do manually. The best way to get started is to learn how to do things manually and then once you have it figured out, make the Python script. Here is a great tutorial to get you started.
Make sure to checkout the “Gotcha’s” section.
From the “Gotcha’s” section: don’t name stuff: https://www.blender.org/api/blender_python_api_2_78a_release/info_gotcha.html#naming-limitations
So you want to use the PyCharm debugger on your Blender code? Here is how:
Running Python Blender Script Non-interactively
From the command line, enter:
blender --background --python myscript.py
Writing Modular Code
First step is to configure Python paths. Pro-tip, when playing with Python paths, it is sometimes helpful to print them:
import sys print(sys.path)
This page shows the layout of default paths. If you choose to put some *.py files in the ./scripts/modules, do not forget to put a __init__.py file in there too.
This is not so much a Blender thing, but more of a 3D modelling thing. There are lots of ways of specifying rotations. Each with it’s own pros and cons. One important way is with quaternions. I have studied a lot of math in my days, but somehow quaternions never came up. To make matters worse, the math behind them is non-trivial. Here is the best free, online tutorial I could find.