How Python implements duplicate object

Hello, I have created a usd scene with some objects in it, I want to duplicate the objects already in this scene through Python, Just like the ‘duplicate’ function in the UI interface, how to implement this, do you have any suggestions?
I’ve looked through the API documentation, but I may not have found it, looking forward to your reply.

Hi @orangechen

You can use the “CopyPrims” command for this


omni.kit.commands.execute("CopyPrims", paths_from=["/World/Cube"], duplicate_layers=False, combine_layers=False)

Thanks for your help, I have successfully implemented it in the Python code.
I still have a question, how to modify the position (position, orientation) generated by the object while copying, or can only modify it after the copying action is over? looking forward to your reply.

Hi @orangechen

As far as I know, there is not a unique function for copy-transform in the same operation…
So, the whole operation has to be done in 2 steps

The closest function to this that I know of is the create_prim method

Thanks for your help, I managed to achieve what I want, I refer to the “CreateMovementComponentCommand” function in Domain-Randomization.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.