Script USDGeomXformable Placement and Visibility on Timeline


I have a few questions and capabilities I’m curious about when it comes to scripting prim placement and visibility in Omniverse.

My goal is to toggle visibility (probably with omni.kit.commands as I do not know the direct Omniverse API that handles visibility toggles - please let me know what that is if you’re familiar) of certain objects in a scene at a certain frame number, and to have the visibility reset once the timeline resets. I would like all children to appear/disappear as well.

My other goal is to set the position of certain USD references based on the current frame number. This I believe I can do with raw USD via their timeline and xform.

The main point of concern for me is that the visibility toggle appears to be an Omniverse function and not something that I can find in base USD.

My questions are:

  1. Is omni.timeline interacting with the same timeline inherently part of a USD file? I looked at the docs and don’t quite understand how to achieve my goals with what’s documented there.

  2. What’s the best way to programmatically toggle the visibility of a prim and its children via python API?

  3. What’s the best way to create events or run scripts at a certain frame of play in Omniverse? Or just in pxr USD?

I appreciate any advice, thank you!

Hi @LMTraina99. This is actually all things that you can do with the USD API and encode directly into your USD data. To understand the frame-based attribute values, I recommend checking out this tutorial: Transformations, Time-sampled Animation, and Layer Offsets — Universal Scene Description 23.05 documentation

Visibility is actually a property and not Omniverse-specific. You can see it listed in the Property window. Once you’ve gone through that tutorial, visibility is a little tricky in that you need to use your Usd.Prim object to create a UsdGeom.Imageable object which has the API for setting visibility: Universal Scene Description: UsdGeomImageable Class Reference

1 Like

Hi Mati,

This is just what I was looking for. I will give it a look!

Thank you!


For anyone with the same question on visibility, you may find that the MakeVisible() function on the UsdGeomImageable class does not behave as desired. It’s probably me screwing something up but here is a useful code snippet as a workaround:

Get the desired prim from an SDF path

currentprim = current_stage.GetPrimAtPath(SOME_SDF_PATH)

Get imageable object from the desired prim

imageable = UsdGeom.Imageable(currentprim)

Set visibility based on user provided time

imageable.GetVisibilityAttr().Set(‘inherited’, Usd.TimeCode(SOME_TIME))
imageable.GetVisibilityAttr().Set(‘invisible’, Usd.TimeCode(SOME_TIME))

You can also use this as your time for initialization purposes


Cheers everyone and thank you again Mati!

1 Like

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