Skip to content

EMSUSD-3340 support drag-and-drop material in AE - #4670

Closed
pierrebai-adsk wants to merge 1 commit into
devfrom
bailp/EMSUSD-3340/ae-DnD-material
Closed

EMSUSD-3340 support drag-and-drop material in AE#4670
pierrebai-adsk wants to merge 1 commit into
devfrom
bailp/EMSUSD-3340/ae-DnD-material

Conversation

@pierrebai-adsk

Copy link
Copy Markdown
Collaborator

New drag-and-drop text field:

  • Added DragAndDropTextField class to make a MEL textField support drag-and-drop of text.
  • The class supports validation of the dropped value.
  • The class has callbacks for user text changes and drag-and-drop changes.

Enhance AE material UI:

  • Use the drag-and-drop text filed in the material custom control.
  • Added AssignedMaterialUI to replace TextField for clarity.
  • Added undo label to matadata UI.
  • Added goto-prim button for all fields with prim paths.

Edit restrictions for material commands:

  • Added edit restriction enforcement in the bind, unbind and strength commands.
  • Made the unbind command not unbind collections. (We're not managing collections.)
  • Added unit tests for restrictions.

New drag-and-drop text field:
- Added `DragAndDropTextField` class to make a MEL textField support drag-and-drop of text.
- The class supports validation of the dropped value.
- The class has callbacks for user text changes and drag-and-drop changes.

Enhance AE material UI:
- Use the drag-and-drop text filed in the material cutom control.
- Added `AssignedMaterialUI` to replace `TextField` for clarity.
- Added undo label to matadata UI.
- Added goto-prim button for all fields with prim paths.

Edit restrictions for material commands:
- Added edit restriction enforcement in the bind, unbind amd strength commands.
- Made the unbind command not unbind collections. (We're not managing
  collections.)
- Added unit tests for restrictions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds UI support for drag-and-drop material assignment in Maya’s Attribute Editor (AE) and strengthens USD material binding command behavior by enforcing edit restrictions, with accompanying unit tests.

Changes:

  • Added a reusable DragAndDropTextField helper and integrated it into the AE material custom control.
  • Improved AE metadata/material UI behaviors (undo labels, goto-prim buttons, clearer controls).
  • Enforced edit restrictions for bind/unbind/strength material commands and added new restriction-focused unit tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/lib/ufe/testMaterialBindingCommands.py Adds unit tests covering edit-restriction failures for bind/unbind/strength commands.
lib/usdUfe/ufe/UsdUndoMaterialCommands.cpp Enforces edit restrictions for material binding operations and adjusts unbind behavior to avoid collection-based unbinding.
lib/mayaUsd/resources/scripts/mayaUsdLibRegisterStrings.py Registers new undo-label strings used by AE controls.
lib/mayaUsd/resources/ae/usdschemabase/metadataCustomControl.py Applies undo labels to metadata edits (kind/active/instanceable).
lib/mayaUsd/resources/ae/usdschemabase/materialCustomControl.py Integrates drag-and-drop text fields and adds goto-prim buttons across relevant material fields.
lib/mayaUsd/resources/ae/usdschemabase/dragAndDropTextField.py Introduces the drag-and-drop-capable text field wrapper used by AE controls.
lib/mayaUsd/resources/ae/CMakeLists.txt Installs the newly added AE Python module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 281 to +287
const UsdRelationship directRel = bindingAPI.GetDirectBindingRel(_purpose);
const TfToken strength = directRel
? UsdShadeMaterialBindingAPI::GetMaterialBindingStrength(directRel)
: UsdShadeTokens->fallbackStrength;

enforceMaterialBindingEditRestriction(directRel);

Comment on lines +89 to +93
potentialNewValue = validation(self.lastValue, newValues)
if potentialNewValue is not None:
return potentialNewValue

return value
In Maya, when text is dropped, it is inserted in the middle of the existing text.
What we want is replacement, not insertion. So we try to detect that and extract
the dropped value from the new text. Unfortunately, there may be corner cases
where we cannot be sure what is teh new text. For example, if the previous text
if self.lastValue == value:
return None
# If the new value is shorter than the last value, it is not a drop.
# If teh new value is just ne character longer, then we assume the user is typing and not dropping.
Comment on lines +168 to +173
hasLookdevX = self._hasLookdevX()
graphIcon = 'LookdevX.png' if hasLookdevX else None

graphTooltip = getMayaUsdLibString('kAnnShowMaterialInLookdevx')
graphButton = cmds.symbolButton(enable=False, image=graphIcon, annotation=graphTooltip)
graphMenu = self._createGraphMenu(graphButton)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants