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 #3487

Closed
wants to merge 1 commit into from

Conversation

pierrebai-adsk
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk commented Nov 29, 2023

Add support to have custom names for USD attributes to have 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. We now read the USD 'displayName' metadata on each attribute. If the metadata exists then we use its value as the display name.

The built-in function to make the name prettier has also been enhanced to remove the "xformOp:" prefix.

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.
  • The displayName function in UsdAttributeHolder prettify the name.

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.

Added a simple unit test.

Add support to have custom names for USD attributes to have 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. We now read
the USD 'displayName' metadata on each attribute. If the metadata exists then
we use its value as the display name.

The built-in function to make the name prettier has also been enhanced to
remove the "xformOp:" prefix. Also, the prettyfying avoids generating two
spaces in a row (if, for example, : was followed by _).

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.
- The displayName function in UsdAttributeHolder prettify the name.

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.

Added a simple unit test and fix some attribute unit tests.

import maya.cmds as cmds

class AEUITemplate:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these is code extracted from ae_template.py, which had a lot of classes inside a single file that got split into their own file. The code did not change.

break
except Exception as ex:
# Do not let one custom control failure affect others.
print('Failed to create control %s: %s' % (c, ex))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a custom control creator failed for any reason, it prevented all other attributes to be handled and there was no error message printed, which made diagnostic harder.

import ufe
import mayaUsd.ufe as mayaUsdUfe
import mayaUsd.lib as mayaUsdLib
import maya.cmds as cmds
import maya.internal.ufeSupport.attributes as attributes

class CustomEnumControl(object):
class EnumCustomControl(AttributeCustomControl):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the class name to follow the same pattern as the others.

InputsInControl = self.searchForMayaControl(frameLayout, cmds.text, 'Inputs In')
self.assertIsNotNone(InputsInControl, 'Could not find D_filename "Inputs In" control')
InputsInControl = self.searchForMayaControl(frameLayout, cmds.text, 'In')
self.assertIsNotNone(InputsInControl, 'Could not find D_filename "In" control')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are shader attributes that now use the UI name. I asked lookdeX and these attributes never were meant to have the "Input" prefix to begin with.

@pierrebai-adsk
Copy link
Collaborator Author

pierrebai-adsk commented Dec 6, 2023

Will remove all refactoring and cleanups and open another PR.

@pierrebai-adsk pierrebai-adsk deleted the bailp/EMSUSD-215/attr-nice-names branch December 6, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants