I have the model of a vehicle body with its wheels and empty coordinates systems at the wheels which are all parented sequentially to the vehicle body. I would like to ask how it is possible to duplicate all the objects and the subsequent relationships using the Python API. In the following image, you can see the relationships that I described; I would like to duplicate this.
How to duplicate an object along with its parent/children relationships using Python in Blender 2.9x
$\begingroup$
$\endgroup$
3
-
$\begingroup$ This copies all objects in a collection, and reparents to a copy if parent also copied. blender.stackexchange.com/a/157855/15543 $\endgroup$– batFINGERCommented Feb 13, 2021 at 15:11
-
$\begingroup$ thank you @batFINGER for your comment. I am new to Blender, so it is still not so clear to me what the script that you provided is doing; I will play with it. If I am not mistaken though, it duplicates a collection. In my case, I would want to just duplicate an object along with its children as I would do from the GUI after selecting everything and copying and pasting them. $\endgroup$– Chris PatrCommented Feb 13, 2021 at 16:41
-
$\begingroup$ In particular, I want to duplicate the ChassisAM (seen in the picture) along with its subsequent relationships. $\endgroup$– Chris PatrCommented Feb 13, 2021 at 16:44
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
I used to bpy.ops.object.duplicate
to duplicate the selected objects coming from the select_set()
method.
In this way, the underlying parent/children relationships are maintained during the duplication.