Creating schemas with prefixes

So we have some custom schemas we’re building where each schema type is Apple<SchemaName> to avoid future conflicts.

e.g AppleCube/AppleGeom to avoid conflicting with a possible Cube
I’m calling it appleCube in this example just to demonstrate a conflict case, but of course we’re not doing a cube.

I have

over "GLOBAL" (
    customData = {
        string libraryName = "appleGeom"
        string libraryPath = "."
        string libraryPrefix = ""
        string tokensPrefix = "AppleGeom"
    }
) {

}

This means that in my USD files I get def AppleCube "Cube" () {...} which prevents future conflicts.

However usdGenSchema generates this plugInfo.json where the alias conflicts with the name of the schema.

"AppleCube": {
                        "alias": {
                            "UsdSchemaBase": "AppleCube
                        }, 
                        "autoGenerated": true, 
                        "bases": [
                            "UsdGeomCube"
                        ], 
                        "schemaKind": "abstractTyped"
                    }, 

This gives a coding error on load of

Coding Error: in AddAlias at line 1226 of OpenUSD/pxr/base/tf/type.cpp -- There already is a type named 'AppleCube' derived from base type 'UsdSchemaBase'; cannot create an alias of the same name.

If I give it a libraryPrefix of Apple, this fixes the issue, but now all my code classes are AppleAppleCube which feels like a lot of redundancy.

Any thoughts on how best to tackle this situation?

Matt answered my question. You use the library prefix as well as the class name to get it to work.

The alias and class name still can’t match but it gives you the flexibility to work around it.

1 Like

This became a problem for us, also, and with this commit for 25.02, we’ll no longer generate the conflicting alias, so no error.

1 Like

Oh that’s really fortuitous timing for us. Thanks, Spiff!