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

Support EditRouter in delete command #3695

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

NickWu
Copy link

@NickWu NickWu commented Apr 4, 2024

Hi, in our pipeline, we have a tool in Maya to delete prims from a specified layer using USD's native API, and we are using the delete key as the hotkey to run the tool. In order the make the prim deletion behaviour consistent between our tool and in Maya viewport (so that users could hit the delete key either with the tool or viewport in focus and get the same result), we'd like to map the delete key in Maya to our prim deletion tool, but we learned that the delete key executed in viewport cannot be remapped and it has been reserved to Maya's cmds.delete() command which has its own logic to delete the selected prims from the layers retrieved based on its own logic. cmds.delete() calls UsdUndoDeleteCommand internally and it doesn't support EditRouter to get an edit target layer from users.

We made these changes in our pipeline to be able to send an UsdEditTarget to UsdUndoDeleteCommand via EditRouter so that a prim can be deleted in a layer we specify. By sending a UsdEditTarget object instead of a SdfLayer, clients have full control on how to construct a UsdEditTarget; if it's constructed with a pcp node, it can delete prims defined in non-local layers, which is one of the main intentions of this update.

The changes are:

  • add getEditRouterEditTarget function in EditRouter to retrieve UsdEditTarget.
  • turn on allowStronger in UsdUfe::applyCommandRestrictionNoThrow to pass the check.
  • add new EditRouter tokens for registering new EditRouter callback for deletion and retrieving UsdEditTarget from callbacks.
  • update wrapEditRouter to be able to retrieve UsdEditTarget object from Python.

@NickWu NickWu changed the title [al] Support EditRouter for delete command [al] Support EditRouter in delete command Apr 4, 2024
@NickWu NickWu changed the title [al] Support EditRouter in delete command Support EditRouter in delete command Apr 4, 2024
Copy link
Collaborator

@pierrebai-adsk pierrebai-adsk left a comment

Choose a reason for hiding this comment

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

Need to fix teh edit context and add a few comments in the code to help us underatdn what is going on in the future.

@NickWu
Copy link
Author

NickWu commented Apr 25, 2024

Hi @pierrebai-adsk , I have added some comments as requested.

@pierrebai-adsk
Copy link
Collaborator

Ran internal preflight #1847 and it passed.

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Apr 26, 2024
@seando-adsk seando-adsk added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Apr 29, 2024
@seando-adsk seando-adsk merged commit cfcbd08 into Autodesk:dev Apr 29, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants