I'd like to improve my duplicator script. bpy.ops.object.duplicate() seems to require me to select the object first. I'd like to just feed the object straight to it instead.
Is there a smarter way to handle it than I did so far?
def duplicator(name):
# select the object
obj = bpy.data.objects.get(name)
obj.select_set(True)
# Loop 3 times, duplicate it, name it
for i in range(1,4):
# duplicate selected object
bpy.ops.object.duplicate()
# name new object with a string and number
newObj = bpy.context.selected_objects[0]
newName = 'Plane_' + str ( i )
newObj.name = newName
duplicator('Plane_0')
new_obj = obj.copy()
$\endgroup$