I have a collection with parts. And I want to replace the mesh data of each object. For that, I use the name of the object and remove the last four characters. (.001, .002, etc).
I made a code, and that works, but only works on the active mesh:
for obj in bpy.data.collections[‘Assets’].all_objects:
bpy.context.object.data.name = bpy.context.object.name[:-4]
What I need is that all the objects need to have it’s mesh data replaced, and not one object from the collection. In other words, how to iterate through a collection and apply operation on all objects within a collection?