Selecting objects in a collection

To select all objects in a collection with the Blender Python API, we need to walk through the list of these objects and call the “select_set” method for each of them, specifying the “True” value in the parameter.

If the required collection is active, we can access it through active collection pointer:

Otherwise, the collection can be referred to by its name:

We can get a list of all objects that are contained in the desired collection through “objects” property:

So we can select all the objects in the collection:

However, this way we can only select objects that are directly in the active collection. If there are nested collections and there are objects in them, these objects will not be selected.

We can select all objects in the collection and in all nested collections at all levels through the “all_objects” collection property:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments