1
$\begingroup$

I try to copy my model and append it as child.

enter image description here Before

enter image description here 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!

$\endgroup$

2 Answers 2

2
$\begingroup$

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"]
$\endgroup$
0
$\begingroup$

It is best to do it without the operator like in the answer by rjg, however after the operator is run the duplicated object becomes the active object, so it's bpy.context.object and if you are duplicating a few objects, all the duplicates become selected so they are all in bpy.context.selected_objects .

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .