8
$\begingroup$

How to get all of the objects assigned to a group in Blender Python?

for group in bpy.data.groups:
    # How to get all objects in group?
$\endgroup$
2
  • $\begingroup$ The count, or which ones are a part of said group? $\endgroup$ Oct 9, 2014 at 15:46
  • $\begingroup$ Did you check the API documentation? - its quite clear. $\endgroup$
    – ideasman42
    Oct 9, 2014 at 15:58

1 Answer 1

8
$\begingroup$

Each group in blender has an 'objects' property which stores all members of that group as a list.

In the context of your script this would loop through each group in the blend file and print the name of each object in that group:

import bpy

for group in bpy.data.groups:
    for object in group.objects:
        print(object.name)

Although, if you simply wanted to access the list, no looping is necessary, you can simply use:

bpy.data.groups['GroupName'].objects

You can then access objects with: ...objects[0].name

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .