Skip to content

transfer_material: preserve the user's selection and warn on per-face sources - #7

Merged
ruxinliang-dev merged 2 commits into
ruxinliang-dev:mainfrom
weijietan09:fix/transfer-material-selection
Aug 24, 2026
Merged

transfer_material: preserve the user's selection and warn on per-face sources#7
ruxinliang-dev merged 2 commits into
ruxinliang-dev:mainfrom
weijietan09:fix/transfer-material-selection

Conversation

@weijietan09

Copy link
Copy Markdown
Contributor

Addresses the first three problems from #6 (the proper per-face re-mapping is left for a follow-up).

  • Selection is restored. The old per-object cmds.select(obj) loop left only the last target selected; the original source+targets selection is now captured up front and restored in a finally.
  • Long names. cmds.ls(selection=True, long=True), matching create_and_assign_material / find_materials, so ambiguous short names under different parents can't select the wrong objects.
  • Single assign call. All targets are selected once and assigned with one cmds.hyperShade(assign=...) — faster, and a single undo entry (same approach as assign_selected_material).
  • Multi-material warning. When the source has more than one material (per-face assignment), the first material is still transferred but the status message now says so instead of printing an unqualified success.

I have already installed it in Maya and tested it in my scenario — selection restore on multi-object transfers and the multi-material warning on a per-face source.

@ruxinliang-dev
ruxinliang-dev merged commit 999c9de into ruxinliang-dev:main Aug 24, 2026
@ruxinliang-dev

Copy link
Copy Markdown
Owner

Thank you for the detailed report, the implementation, and the Maya testing. I really appreciate the time you put into identifying the issue and preparing this contribution.

I’ve pushed a maintainer follow-up commit on top of your original work. Your original commit and authorship have been preserved.

The follow-up changes:

  • cancel multi-material transfers before modifying any targets;
  • deduplicate material results;
  • group the complete operation into one Maya undo chunk;
  • restore the original selection and close the undo chunk even if assignment fails;
  • clarify the long-DAG-path explanation;
  • add automated coverage for successful assignment, multi-material cancellation, and assignment failure.

All three automated tests pass.

The full per-face material remapping will remain in #8.

Thanks again for the contribution.

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