The thing is that I have a collection with multiple parent objects and I need to join these parents with their children. I have tried to iterate over each object in the collection with a For Loop, but I cannot get the result that I am looking for.
Here I attach an image to explain my point more clearly. I am iterating over the 'Openings' collection, and I want to join every single door and window with its own children.
I have tried many things, but I am new to Python and I cannot find a way.
My code so far is this:
import bpy
for obj in bpy.data.collections['Openings'].all_objects:
parent_obj = bpy.context.active_object
parent_obj.select_set(True)
bpy.ops.object.select_grouped(type='CHILDREN_RECURSIVE')
bpy.ops.object.join()
I am pretty sure this code is wrong, but the others options I have tried do not work either.
I am using Blender 3.1 version.
I hope someone could help me with this and thanks in advance.
