Retrieving inherit path from within instanceable proxy

Hello:
I have a case where I have an inherits arc inside of an instanceable proxy. When I introspect the prim using .GetInherits().GetAllDirectInherits() or using a prim composition query, this returns to me the path to the hidden proxy objects path. This is completely logical because it is actually inheriting from there, but my goal is more of a user interface one. I’d like to return to a user the path to the inherited object if this path wasn’t in an instance proxy.

In this image, LotsOfBoxes1 is instanceable. LotsOfBoxes1/Geo/Box1 has an inherits of LotsOfBoxes1/Sources/BoxRef. But, when querying it’s inheritance through those calls mentioned above, I usually get LotsOfBoxes3/Sources/BoxRef (This being whatever instance was chosen as the proxy by USD under the hood?)

Is there a method, given the prim at LotsOfBoxes1/Geo/Box1 I could find my way back to LotsOfBoxes1/Sources/BoxRef? My goal is to provide a method that when you right click on Box1, it’d select the BoxRef under ListOfBoxes1 it is inheriting from, from a users perspective.

USD files for the scene and a simple python script are attached.
Thank you!

inheritsResolve.zip (1.4 KB)

1 Like

I don’t think there’s anything in core that directly supports this. While I believe the wg-usd-assets guidance promotes using inherits arcs to directly establish native instancing, at Pixar, outside of the context of rigging setups, we structure our assets with only global inherits on model root prims, and establish instancing using reference arcs to those prims. This sidesteps such translation / prototype-selection issues because global remains global even as inherits propagate (“imply”) across referencing, instancing, and embedding inside large assets. It does come with the cost/complexity of needing to use UsdEditTargets to author into targets inside the global class prim, whereas the wg-usd structure allows you to directly edit “the sources”.

To get the path you’re looking for, I think the only straightforward way would be to compute your own PcpComputeExpandedPrimIndex() on the full proxy prim path of the prim you’re interrogating. But then you need to walk through the index yourself the same way UsdPrimCompositionQuery does. We use the prototype PrimIndex rather than the uninstanced prim’s Index not only for efficiency (because we cache it, as the expanded prim index is expensive to compute), but also because the results could be different if there were overrides on the child-of-instance-prim in the local layerstack that added composition arcs, because all of those overrides are ignored when the parent/ancestor is instanced.

I’ll ask around if anyone has other ideas…

Thank you for the detailed description Spiff! I will take you information under advisement and see if using the PcpComputeExpandedPrimIndex is a path I can follow. If not, then perhaps I can just display to the user a warning about introspecting proxy prims.