Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EMSUSD-215 support custom display name for USD attributes
Add support to modify the names of USD attributes to nicer names for UI display purpose. We already had an algorithm to automatically make the names prettier, this adds support for user-defined attribute names. The user-defined attribute names are defined in a JSON file named "attribute_mappings.json". There are two such files in two locations: - one in the `lib` folder under the installation folder of the plugin. - one in the `prefs` folder of the user Maya folder. Each such file contains a section for prefixes to be removed and a section to map attribute names to nicer names. Note that the mappings are applied after the prefixes are removed. The format of these JSON files is shown in the following example: { "version": 1.0, "removed_prefixes": [ "abc", "def" ], "attribute_mappings": { "example-attribute-name": "example-display-name", "foo": "bar", }, } The built-in attribute mappings do the following: - Remove the "xformOp:" prefix. - Map "xfor - Map "xformOpOrder" to "Transform Order". Modify the USD attribute-related classes: - Add a displayName funtion to the UsdAttrbute class. - Add a displayName funtion to the UsdAttributeHolder class. - Add a displayName funtion to the UsdShaderAttributeHolder class. Add support for display name in the Attribute Editor template: - Refactor custom-control for various types into their own files. - Add a AttributeCustomControl base class to handle display names. - Make the default control creation use the display names. Add new support functions: - Add new JSON helper function to convert floating-point values. - Add the getMayaPrefDir function to get the preference folder. - Add the joinPaths function to join together multiple file paths. - Add loadAttributeNameMappings function to load the user-defined attribute name mapping from the JSON file. - Add getAttributeDisplayName function to convert an attribute name into its display name. - Use the plugin location to derive the built-in file location. Added a simple unit test.
- Loading branch information