Script : mirror

Its probably basic : For every object in the scene that has “right” in its name I need to create a copy object on the left, but mirrored relative to the origin. I tried to use the code that appear in the Info panel when I do this mirroring manually. Before I (try to ) select the object to be mirrored. No mirroring occurs.

for  o in bpy.context.scene.objects:
if  "right" in :
    new_left = o.copy() ="right", "left") = new_left
    bpy.ops.transform.resize(value=(1, -1, 1), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=0.263331, use_proportional_connected=False, use_proportional_projected=False)
    bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)

There were some changes since 2.8, right ?

Thank you for any advice you can give me ! Nicolas

For me it work, except:

That is not working with copy, dont know why. But you can use
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={“linked”:False, “mode”:‘TRANSLATION’}, TRANSFORM_OT_translate={“value”:(0, 0, 0), “orient_type”:‘GLOBAL’, “orient_matrix”:((0, 0, 0), (0, 0, 0), (0, 0, 0)), “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, “release_confirm”:False, “use_accurate”:False})

Also you can try
bpy.ops.object.modifier_apply(apply_as=‘DATA’, modifier=“Mirror”)

Thanks for your help Rigoletto,
I used you first command. But I need to change the new object’s name (the one produced by the duplicating).
How can I reach it ?
I tried this but it didn’t work :

for  o in bpy.context.scene.objects:
    if  "droit" in :
        = o
        bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "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, "release_confirm":False, "use_accurate":False})   
        newObj = bpy.context.selected_objects[0] ="droit", "gauche")
        if  not "scripted" in :  
   = "scripted--" +

In fact, I don’t really understand what bpy.ops.object is …
Thanks !!

For me your script worked without errors, it duplicates and renames.

bpy.ops is for accessing the operators from blender, in this case the object operators, like add, move, …
API docs are here:

Also take a look at the python console, there you can do autocomplete with TAB and browse trough the provided functions and call the docs via help.