E-Book, Englisch, 360 Seiten
Acampora Python Scripting in Blender
1. Auflage 2023
ISBN: 978-1-80324-327-6
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
Extend the power of Blender using Python to create objects, animations, and effective add-ons
E-Book, Englisch, 360 Seiten
ISBN: 978-1-80324-327-6
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
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.
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
Table of Contents - Python's Integration with Blender
- Python Entities and APIs
- Creating Your Add-Ons
- Exploring Object Transformations
- Designing Graphical Interfaces
- Structuring Our Code and Add-Ons
- The Animation System
- Animation Modifiers
- Animation Drivers
- Advanced and Modal Operators
- Object Modifiers
- Rendering and Shaders
Preface
Blender is a free, open source application for 3D modeling and animation. It has evolved over the years and, since version 3.0, is on par with state-of-the-art software in many aspects.
It provides a Python Application Programming Interface (API) for automating tasks, adding functionalities, and integrating Blender in large productions.
Python is a free, open source programming language for quick yet powerful scripting. Its syntax, akin to simplified English, automatic memory management, and ease of integration, makes it the standard in software APIs and 3D pipelines.
This book goes through the steps of the 3D process, starting with the creation and manipulation of objects, then animation and deformation follow, with rendering as the closing chapter. Though this order is a linear path, every chapter can stand on its own, with the exception perhaps of , and , which rely on examples introduced in their immediate predecessor.
Who this book is for
This book is for users of Blender who want to expand their skills and learn to script, technical directors who want to automate laborious tasks, and professionals and hobbyists who want to learn more about the Python architecture of Blender.
What this book covers
, , teaches you how to run Python instructions in Blender, and use external editors and version control.
, , teaches you how to set up options for developers, and how to use Blender modules and access the current context and objects.
, , teaches you how to write Blender add-ons using Python, how towrite operators, and how to add entries to Blender menus.
, , teaches you how location, rotation, and scale are handled in Python, how to use object constraints and transform matrices, and how to use input properties in operators.
, , provides information on how the Blender user interface works, how to create and arrange your own panels, and how to load custom icons and display buttons for custom functions.
, , teaches you how to write and distribute modular addons, how to display add-on preferences, and how to update changes in your modules.
, , teaches you how to access and create animation data, how to script procedural motions, and how to extrapolate rotations.
, , instructs you on how to add non-destructive modifiers to animations, and how to use them for animated procedural effects.
, , teaches you how to set up inputs for animation channels, how to drive animations with Python expressions, and how to convert the oscillation formula to animated objects.
, , teaches you how to customize the operator execution flow and how to respond to input events in your operators.
, , provides information on how object modifiers, armatures, and lattices work, and how to set up animation controls of deformed objects.
, , teaches you how color and material information is applied to objects and how that process can be automated.
To get the most out of this book
The examples in this book were written and tested using Blender version 3.3. Version 3.3 is a long-term support release and can be found on most application platforms, besides being available for free at Blender.org.
Using a programmer text editor is advised. Microsoft Visual Studio Code 1.70, a lightweight free editor available on most operating systems, is used in this book, but any other editor can be used.
More instructions on how to install the software are provided in .
The scripts contained in the book were written with forward compatibility in mind. The code available online will be updated to accommodate changes in future releases.
It is assumed that you have some experience with Blender and at least a basic understanding of how Python works, but special effort was put into keeping those requirements low and providing explanations for every concept used in this book.
| Software/hardware covered in the book | Operating system requirements |
| Blender 3.3 | Windows, macOS, or Linux |
| Visual Studio Code 1.70 or later |
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Python-Scripting-in-Blender. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/G1mMt.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “The fcurve.modifiers.new(type) method creates a new modifier according to the type provided in the argument. It returns the new modifier.”
A block of code is set as follows:
bl_info = { "name": "Object Shaker", "author": "Packt Man", "version": (1, 0), "blender": (3, 00, 0), "description": "Add Shaky motion to active object", "location": "Object Right Click -> Add Object Shake", "category": "Learning", }When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
sin((frame / fps) * 2 * pi / (2 * pi * sqrt(length/9.8)))Any command-line input or output is written as follows:
['ASSETBROWSER_MT_context_menu',...['VIEW3D_MT_edit_metaball_context_menu', 'VIEW3D_MT_gpencil_edit_context_menu', 'VIEW3D_MT_object_context_menu', 'VIEW3D_MT_particle_context_menu',...Some of the code is meant to be used as input for the interactive Python Console. In that case, the user input is preceded by the >>> prompt, unlike the console output:
>>> print("Hello") HelloBold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Before we delve into how f-modifiers are scripted, we will have a look at how to create them in Graph Editor.”
Tips or important notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be...




