I am trying to duplicate multiple objects resulting in the same location/rotation relative to each other. I can get my code to work for a single object but when multiple objects are used obviously the objects get transformed N times (N number of multiple objects). Is there a function that I am missing or a different approach?
import bpy
import bmesh
bm = bmesh.new()
for i, o in enumerate(bpy.context.selected_objects):
bm.from_mesh(o.data)
bm.transform(o.matrix_world)
me = bpy.data.meshes.new("Mesh")
bm.to_mesh(me)
obj = bpy.data.objects.new("Object", me) # https://docs.blender.org/api/current/bmesh.ops.html
bpy.context.collection.objects.link(obj)