Book Image

Python Scripting in Blender

By : Paolo Acampora
5 (1)
Book Image

Python Scripting in Blender

5 (1)
By: Paolo Acampora

Overview of this book

Blender, a powerful open source 3D software, can be extended and powered up using the Python programming language. This book teaches you how to automate laborious operations using scripts, and expand the set of available commands, graphic interfaces, tools, and event responses, which will enable you to add custom features to meet your needs and bring your creative ideas to life. The book begins by covering essential Python concepts and showing you how to create a basic add-on. You’ll then gain a solid understanding of the entities that affect the look of Blender’s objects such as modifiers, constraints, and materials. As you advance, you’ll get to grips with the animation system in Blender and learn how to set up its behavior using Python. The examples, tools, patterns, and best practices present throughout the book will familiarize you with the Python API and build your knowledge base, along with enabling you to produce valuable code that empowers the users and is ready for publishing or production. By the end of this book, you’ll be able to successfully design add-ons that integrate seamlessly with the software and its ecosystem.
Table of Contents (19 chapters)
1
Part 1: Introduction to Python
7
Part 2: Interactive Tools and Animation
13
Part 3: Delivering Output

Understanding object modifiers

Object modifiers change the displayed status of an object without altering its geometric data. We met something similar in Chapter 8, when we applied effects to animation F-Curves without changing their keyframes.

Like F-Modifiers, they can be stacked on each other and accessed in Python as a collection property.

Modifiers can be added manually, but their creation and setup can be scripted as well. Before we delve into the API, let’s take a look at how to create them in the Modifiers properties.

Adding modifiers

Object modifiers are created in the Modifiers tab of Properties using the Add Modifier drop-down button. The tab is marked with the icon of a wrench.

Figure 11.1: Adding modifiers in Blender

Figure 11.1: Adding modifiers in Blender

Clicking Add Modifier displays the available options. They change according to the object type: curves don’t have as many modifiers as meshes, while nongeometric types such as empty or cameras can’...