I am using this code which works very well for one object. I select
Object_A and it moves to the collection
MyCollection. If I select two or more objects, how would I change the code?
bpy.data.objects['Object_A'].select_set(True) obj = bpy.context.window.scene.objects['Protrusive'] bpy.context.view_layer.objects.active = obj A = bpy.context.object A_old_coll = A.users_collection terrain_coll_name = "MyCollection" if terrain_coll_name not in bpy.data.collections: terrain_coll = bpy.data.collections.new(name=terrain_coll_name) bpy.context.scene.collection.children.link(terrain_coll) else: terrain_coll = bpy.data.collections[terrain_coll_name] terrain_coll.objects.link(A) for ob in A_old_coll: ob.objects.unlink(A)