Search icon CANCEL
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

Accessing Blender data

All the entities created in the current session are available as part of bpy.data. They are grouped in categories that follow the object types available in Blender, so we have bpy.data.armatures, bpy.data.curves, and so on. Each category is a bpy_collection, a Blender type that contains more elements. Their content can be accessed with indices, like in a Python list, or with keywords, like in dictionaries.

Objects access

We can use Python to access the objects of a scene. For example, we can query the content of Blender’s default scene, which contains a Cube, a Camera and a Light:

  1. Open or restart Blender and select Scripting Workspace in the workspace tabs at the top of the screen.
Figure 2.10: The workspace tabs

Figure 2.10: The workspace tabs

  1. Type len(bpy.data.objects) and press Enter:
    >>> len(bpy.data.objects)
    3
  2. In the Python console, type bpy.data.objects, then press Tab.
Figure 2.11: Blender’s default objects

Figure 2.11: Blender...

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 €18.99/month. Cancel anytime