Is it possible to query all available single/multi-apply API schemas?
I’m having a hard time finding how to obtain such a list, been looking at SchemaRegistry but can’t figure it out.
Workflow is to allow a user to browse a list, select one, and apply it to a prim (if it can apply).
Hi @ScottRenaud , you’re right there’s no API on UsdSchemaRegistry for enumeration. It makes sense that you’d expect such API there, though I’m a little hesitant about us adding such before we have tackled the “per-stage schemas” project, which may result in schemas unknown to the SchemaRegistry singleton.
What we do in Presto and other apps is rely on the TfType system for enumeration. Fetch the TfType for UsdSchemaBase, and then call GetAllDerivedTypes() on the returned object, whic hwill get you the TfTypes of all registered schema classes. You can segregate just the API schemas by instead using UsdAPISchemaBase
from pxr import Usd, Tf
schema_reg = Usd.SchemaRegistry()
single_apply_list = []
multiple_apply_list = []
for t in Tf.Type.FindByName("UsdAPISchemaBase").GetAllDerivedTypes():
if not (schema_reg.IsAppliedAPISchema(t) or schema_reg.IsMultipleApplyAPISchema(t)):
continue
if (schema_reg.IsAppliedAPISchema(t) and not schema_reg.IsMultipleApplyAPISchema(t)):
single_apply_list.append(str(t).split("'")[1::2][0])
if (schema_reg.IsMultipleApplyAPISchema(t)):
multiple_apply_list.append(str(t).split("'")[1::2][0])
# Sort and print
print("Single-apply API Schemas:")
for x in sorted(single_apply_list):
print(x)
print("\nMulti-apply API Schemas:")
for x in sorted(multiple_apply_list):
print(x)
Great, @ScottRenaud , though note that the multi-apply schemas are also showing up in your Single-Apply list, because IsAppliedSchema answers true for both. You probably want to additionally use the negation of IsMultipleApplySchema for the single-applies.