0

Im really struggling with what seems to be an easy task, however Im not able to make this work.

I need to get the parent inside of a collection that's already in a collection,

with the code im using

    print(collection)
    if collection.name == doorname:
        door = collection.children[0]
        print(door) //OUTPUT: <bpy_struct, Collection("Door") at 0x7ff8f180b678>
        for objects in door:
            print(objects) //Error 

I want all the objects in the Door collection to be printed. Is there a way to do this, what am I missing?

Thanks in advance!

susu
  • 14,002
  • 3
  • 25
  • 48
HENRyyy
  • 1
  • 1
  • 1
    Suggest this is for o in door.objects or for o in door.all_objects to get all objects in door collection and its children. – batFINGER Feb 24 '21 at 10:48
  • 1
    See also https://blender.stackexchange.com/questions/145620/looping-over-hierarchies-of-objects-with-python .. Can you clarify, comment above addresses error in code, whereas https://blender.stackexchange.com/questions/146685/how-to-obtain-the-parent-of-a-collection-using-python would appear to answer the question title. – batFINGER Feb 24 '21 at 10:57

1 Answers1

0

Maybe for objects in door.children since you're parenting them?

enter image description here

Yeah it could be cool to use magic method looping over children

HikariTW
  • 7,821
  • 2
  • 18
  • 37