# Objects duplication

I'm having some problems with duplication in blender. I wanted to create python function to make a circle of projectiles in a list from one projectile.
But when I duplicate it, the new object is selected and the next ones are created from the previous ones.

if someone have a solution, that would help me

thanks

• Can you cut and paste your script fragment as text in your question? Jan 23 at 18:17
• I agree with @MartyFouts that if you copy paste the script into your question, none of us have to go to the effort of (mostly) rewriting your script. Jan 23 at 18:34
• Found the solution, just needed this line : bpy.ops.object.select_all(action='DESELECT') Jan 23 at 18:47

Not being able to copy/paste your script, I'll not rewrite it all here. But here are some additions I'd make, to "reselect" your initial object.

I would first have an obj that references your initial selected object, and then after each duplication, have the script select that object again (instead of the duplicate object automatically selected). So before the loop I'd add:

objOrig =bpy.context.selected_objects[0]

so you save it for future reference, and then after the duplicate_move statement inside the loop I'd add the two statements:

 bpy.ops.object.select_all( action='DESELECT' ) # Deselect all objects

 objOrig.select_set(True) # reselect the original object

Example:

import bpy

obj1=bpy.context.selected_objects[0]
newx=1

for i in range(1,10):
TRANSFORM_OT_translate={"value":(newx, 1, 1), "orient_axis_ortho":'X', "orient_type":'GLOBAL',
"orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL',
"constraint_axis":(False, False, False), "mirror":False, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH',
"proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST',
"snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False,
"texture_space":False, "remove_on_cancel":False, "view2d_edge_pan":False, "release_confirm":False, "use_accurate":False,
"use_automerge_and_split":False})

bpy.ops.object.select_all( action='DESELECT' ) # Deselect all objects
obj1.select_set(True)
newx+=1


def Object_Duplication(new_x, new_y, new_z):
return bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(new_x, new_y, new_z), "orient_axis_ortho":'X', "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "view2d_edge_pan":False, "release_confirm":False, "use_accurate":False, "use_automerge_and_split":False})

# Turning one projectile into a circle of projectiles
# Getting params from original object
base_x = Projectile.location.x
base_y = Projectile.location.y
base_z = Projectile.location.z
New_Collection

for i in range(0,quantity):
# Deselecting all then selecting the original object
bpy.ops.object.select_all(action='DESELECT')
Projectile.select_set(True)

# New coordinates calculation for the next projectile
theta = (i/quantity)*3.14*2
new_x = base_x + radius*cos(theta)
new_y = base_y
new_z = base_z + radius*sin(theta)

# Duplicating the next projectile
Object_Duplication(new_x, new_y, new_z)


This is what I have done and it worked, I will try putting them in a new collection so i can only select the new duplicated items.

thanks for the answer