How do you find the Current Session and root layer Id?

I noticed if I use the Commands extension, and create a Ground Plane, I get something like this as a Session Id.
anon:0000026AA88A0390:World0.usd

omni.kit.commands.execute(‘AddGroundPlaneCommand’, stage=Usd.Stage.Open(rootLayer=Sdf.Find(‘anon:0000026AA88A0390:World0.usd’), sessionLayer=Sdf.Find(‘anon:0000026AA88A0480:World0-session.usda’)),
planePath=‘/GroundPlane’,
axis=‘Y’,
size=2500.0,
position=Gf.Vec3f(0.0, 0.0, 0.0),
color=Gf.Vec3f(0.5, 0.5, 0.5))

If I then create a new project, do the same thing, I get a new session Id.
anon:000002768BE1B740:World1-session.usda

omni.kit.commands.execute(‘AddGroundPlaneCommand’,
stage=Usd.Stage.Open(rootLayer=Sdf.Find(‘anon:000002768BE1C0A0:World1.usd’), sessionLayer=Sdf.Find(‘anon:000002768BE1B740:World1-session.usda’)),
planePath=‘/GroundPlane’,
axis=‘Y’,
size=2500.0,
position=Gf.Vec3f(0.0, 0.0, 0.0),
color=Gf.Vec3f(0.5, 0.5, 0.5))

So the code to create a ground plane won’t work in an extension because the session Id is different every project.

Is there either a way to find this Id, or create a ground plane and add a material without knowing the session Id?

Thank you,

Hi @DataJuggler

What about getting and passing the current stage using stage = omni.usd.get_context().get_stage() as shown in this other post: I created my first extension and didn't work - sdf not defined - #2 by toni.sm

Even that post had a similar anon id.

omni.kit.commands.execute(‘AddGroundPlaneCommand’,
# stage=Usd.Stage.Open(rootLayer=Sdf.Find(‘anon:0000014AF6CD0760:World0.usd’), sessionLayer=Sdf.Find(‘anon:0000014AF6CD0B20:World0-session.usda’)),
stage=stage,

Don’t you agree with me that having ID’s like that which come from your Commands extension, only work on the current scene. Sounds like that should be something more generic like name, not anon:(id).

Hi @DataJuggler. @toni.sm’s answer is correct. We are working on better commands examples in the docs that will make that less confusing and we will hopefully also provide better output from the Commands History Window.

Thank you.

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