I want to alert my users if a sublayer is not loaded. Is there a method to check for unloaded layers? My current approach is to walk each layer/sublayer and check if each path in layer.sublayerPaths is in the layer.GetLoadedLayers list. Looking for a more performant or existing approach.
Hi @Nick , we were wondering if by “unloaded layers” you meant (any or all of):
- layers that have errors in them that prevented them from being loaded
- layers that have been “muted” on the Stage
- are you anticipating any layers that leverage “variable expressions” for inclusion into the stage?
Independently, are you concerned only with layers in the root layerStack, or also layers from “across references”?
My current issue is layers that cannot be found on disk, deleted or moved.
The “composition engine” underneath the UsdStage keeps track of the errors it encountered while (last re-)composing the stage, including which layers it could not find. The completion of the validation project we are undertaking will provide easier access to these errors.
If you are primarily interested in the missing “root layerstack” layers (which is what the technique you are currently using will give you), then after opening the stage, you should be able to get at the errors that will contain such information like (in python):
pr = stage.GetPseudoRoot()
# if root layer wasn't found then pr will be None
errors = pr.GetPrimIndex().rootNode.layerStack.localErrors