Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-215 support custom display name for USD attributes #3485

Closed
wants to merge 2 commits into from

Conversation

pierrebai-adsk
Copy link
Collaborator

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 "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.

@pierrebai-adsk pierrebai-adsk added enhancement New feature or request adsk Related to Autodesk plugin labels Nov 29, 2023
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.
@pierrebai-adsk pierrebai-adsk deleted the bailp/EMSUSD-215/attr-nice-names branch November 29, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants