2

How can I join all objects in a collection? This is what i have so far:

def final():
    Coll=bpy.data.collections['low']
    #finalColl=bpy.data.collections['final']
    for obj in Coll.objects:
        if obj.type=='MESH':
           ob.join
Zak Nelson
  • 861
  • 7
  • 17

1 Answers1

1

You have to make sure you have selected all the objects you want to join using obj.select_set(True) in the for loop and make sure one of the objects is active (yellow outline). Then you can join them using bpy.ops.object.join() after the loop has finished.

import bpy

def final(): bpy.ops.object.select_all(action='DESELECT')

    Coll = bpy.data.collections['low']
    for obj in Coll.objects:
        if obj.type == 'MESH':
           obj.select_set(True)
    #bpy.context.view_layer.objects.active = bpy.data.objects["Cube"]
    bpy.ops.object.join()

final()

Harry McKenzie
  • 10,995
  • 8
  • 23
  • 51