How to get duplicate id via python api? I try to copy my model and append it as child.


Before


After

When I try to duplicate by bpy.ops.object.duplicate().

It will return {'FINISHED'} which is not useful for accessing it!

I can't put any operation when the item id is unknown!
If you need the object for further operations it's best to do the duplication without the operator.

data_copy = bpy.data.objects["Cube"].data.copy()
obj_copy = bpy.data.objects["Cube"].copy()
obj_copy.data = data_copy
bpy.data.collections["Collection"].objects.link(obj_copy)
obj_copy.parent = bpy.data.objects["Cube"]