Help needed in executing code generated from Command window

Hello,

I am using the Commands window to see the underlying snippet that is generated when Linear Drive is removed from a Prismatic Joint. The generated code is as below

import omni.kit.commands
from pxr import UsdPhysics, Usd

omni.kit.commands.execute('Group')

omni.kit.commands.execute('RemovePhysicsComponent',
	usd_prim=Usd.Prim(</PrismaticJoint>),
	component='PhysicsDrive',
	multiple_api_token=None)

omni.kit.commands.execute('RemovePrismaticPhysicsJointComponent',
	component='PhysicsDrive',
	usd_prim=Usd.Prim(</PrismaticJoint>))

omni.kit.commands.execute('UnapplyAPISchema',
	api=<class 'pxr.UsdPhysics.DriveAPI'>,
	prim=Usd.Prim(</PrismaticJoint>),
	api_prefix='PhysicsDrive',
	multiple_api_token='linear')

The code snippet cannot be executed due to syntax errors.

I am curious what are the correct values for below line of code.

usd_prim=Usd.Prim(</PrismaticJoint>) # I tried changing that to path of Prismatic Joint but that didn't worked
...
...
...
api=<class 'pxr.UsdPhysics.DriveAPI'>, # what is the correct value here?

Is there any reference to documentation available with examples?

Thanks in advance.

Hi there. Is this error occurring in Isaac Sim? You need to post this in the ISAAC SIM page. Latest Omniverse/Isaac Sim topics - NVIDIA Developer Forums

@Richard3D I am using USD Composer for code generation using command history.

OK just to clarify your question, you were saying that you have copied this block of code from the command console and you trying to run it as a new command and it’s not working as expected? And what exactly is the syntax error you are getting?

@Richard3D I copied the generated code and tried executing it in my Python script. That’s where I am getting the error because the code generated is breaking the Python syntax.

Please let me know if you need any more information.

OK let me see if I can get somebody to help you with those specific commands

@AlesBorovicka

This is the command we use for the DriveAPI removal:

execute("UnapplyAPISchema", api=UsdPhysics.DriveAPI, prim=self._usd_prim, api_prefix="PhysicsDrive", multiple_api_token="linear")

Thank you. I will give a try.
Looks like the code generated in Command History extension needs a fix to incorporate this.

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