Duplicating and moving object


is it possible to duplicate and move an object to an absolute position?
explanation: i’m trying to create a script to build… buildings, based on premade sets of windows, doors, etc. but if I use bpy.ops.object.duplicate_move_linked(OBJECT_OT_duplicate={"linked":True, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(3, 0, 0)}), the new object will be moved 3 points in X axis relative to the original object; so, if the original is in position (10, 0, 0), the duplicate will be in (13, 0, 0). is there any way to set the absolute position of the duplicated object (apart from just subtracting the original object’s position, since with too many prefabs that could get overly complicated)?


better to just do it via the data api rather than a built-in operator:

# the new object is created with the old object's data, which makes it "linked"
my_new_obj = bpy.data.objects.new("my new object", bpy.data.objects['original_object'].data)

# now it's just an object ref and you can move it to an absolute position
my_new_obj.location = (3,0,0)

# when you create a new object manually this way it's not part of any collection, add it to the active collection so you can actually see it in the viewport

perfect. thanks :smiley: