I have a script that creates a bunch of objects and at the end joins all the objects in the scene into one big object using this piece of code:
bpy.context.view_layer.objects.active = bpy.data.objects["Base"] bpy.ops.object.select_all(action="SELECT") bpy.ops.object.join()
This works fine if I start with an empty scene, and then copy the final object into my main scene. However, I would like to have a script that creates a new object in the main scene, so I need a way to join all the objects created with the script, and not the ones already in the scene.
I thought of adding some unique prefix to all the created objects, then selecting all the objects with that prefix, join them, and finally remove the prefix from the final object, but that solution seems very tedious and wrong.
How would you solve this?