However, I found that the USD commands cannot be executed without any warnings and errors.
I have used “CopyPrimCommand” as an example in the following script. Copying prim has been executed with 3 different commands, i.e. “omni.usd.duplicate_prim”, “omni.usd.commands.CopyPrimCommand”, and “omni.kit.commands.execute”. The USD command doesn’t work.
The script I have used:
import omni.usd
import omni.usd.commands
import omni.kit.commands
Hi @hippo_family. omni.kit.commands.execute is the correct way to call the command.
Creating an object of the command like you did in the second case does not execute the command. You need to call the do() function of the command object. You generally don’t want to do that though because it bypasses the Command history.
Yes. The omni.kit.commands framework is used to execute all Kit commands no matter which extension may register a command. More info here about omnil.kit.commands: Overview — omni.kit.commands 1.4.6 documentation