Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Scripting in Blender

You're reading from   Python Scripting in Blender Extend the power of Blender using Python to create objects, animations, and effective add-ons

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781803234229
Length 360 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Paolo Acampora Paolo Acampora
Author Profile Icon Paolo Acampora
Paolo Acampora
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Part 1: Introduction to Python
2. Chapter 1: Python’s Integration with Blender FREE CHAPTER 3. Chapter 2: Python Entities and API 4. Chapter 3: Creating Your Add-Ons 5. Chapter 4: Exploring Object Transformations 6. Chapter 5: Designing Graphical Interfaces 7. Part 2: Interactive Tools and Animation
8. Chapter 6: Structuring Our Code and Add-Ons 9. Chapter 7: The Animation System 10. Chapter 8: Animation Modifiers 11. Chapter 9: Animation Drivers 12. Chapter 10: Advanced and Modal Operators 13. Part 3: Delivering Output
14. Chapter 11: Object Modifiers 15. Chapter 12: Rendering and Shaders 16. Index 17. Other Books You May Enjoy Appendix

Adding modifiers in Python

The Python class of Blender objects contains a modifiers attribute. Like all collections, modifiers provides the new method, which creates and returns new items. By using new, we can automate the setup of modifiers using Python.

Finding collection-type items

Object.modifiers.new takes two arguments: name and type. The first will be displayed in the modifier properties in the interface, while type specifies which kind of modifier we want to create. The type argument must belong to the list of available types, or it will cause an error. Available types are listed in the API documentation:

https://docs.blender.org/api/3.3/bpy_types_enum_items/object_modifier_type_items.html

But we can also get them from Blender itself. These commands will list the modifier keywords in Blender’s Python console:

>>> import bpy
>>> mod_rna = bpy.types.ObjectModifiers.bl_rna
>>> mod_params = mod_rna.functions["new"].parameters...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime