I've created a mesh I want to duplicate using python with specifications for the new duplicate's coordinates. How do I do that?


You can simply use Object Duplicate Operator on the selected object(s) in Object Mode:


By default this will create an identical copy, like pressing Shift+D in 3d View. By passing linked=True to the operator, you can also create a linked duplicate like pressing Alt+D on the keyboard. This will create a new object with all of its data (like the mesh) linked to the original object.

To adjust the location, access the Active Object (which is the duplicate in this case) and simply overwrite the location values:

bpy.context.object.location = (x, y, z)

When duplicating multiple objects use bpy.context.selected_objects to get a list of the created duplicates afterwards. Iterate through the list and assign new position values to each object.

For more options, see this question: Python move object on local axis


You can create a copy of the Mesh datablock, create a new Object, position it where ever you want and attach it to the current scene like this:

import bpy

me = bpy.context.object.data # use current object's data
me_copy = me.copy()

ob = bpy.data.objects.new("Mesh Copy", me_copy)
ob.location = (1,2,3)

scene = bpy.context.scene

You may also duplicate the original object. If you set the new object's data attribute to the original mesh datablock (no mesh copy created), it will be a linked duplicate.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.