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

MAYA-129059 - Add command to create stages. #3045

Merged
merged 1 commit into from
May 31, 2023

Conversation

frohnej-adsk
Copy link
Collaborator

Add an undoable command that creates a stage with a new layer.

The new command is a C++ implementation of the existing mayaUsd_createStageWithNewLayer.py Python script. The command enables the creation of stages from within the C++ code, which will be required by future work (MAYA-128151) and might also be generally useful.

This commit also adds a Python binding for the stage creation command, which is used in mayaUsd_createStageWithNewLayer.py to replace the current implementation.

@frohnej-adsk frohnej-adsk added the do-not-merge-yet Development is not finished, PR not ready for merge label Apr 28, 2023
@frohnej-adsk frohnej-adsk force-pushed the frohnej/MAYA-129059/createStageCommand branch from 20dc6a9 to defb109 Compare May 3, 2023 10:49
@frohnej-adsk frohnej-adsk removed the do-not-merge-yet Development is not finished, PR not ready for merge label May 3, 2023
@ppt-adsk ppt-adsk removed their request for review May 3, 2023 20:11
@ppt-adsk
Copy link
Collaborator

ppt-adsk commented May 3, 2023

Hi @frohnej-adsk, I won't be reviewing this one. I will say that it needs a unit test :)

@frohnej-adsk frohnej-adsk force-pushed the frohnej/MAYA-129059/createStageCommand branch from 0f221dc to 60e93f7 Compare May 4, 2023 12:45
@seando-adsk
Copy link
Collaborator

@frohnej-adsk Before I review this code I just have a general question. In the comments you say that this will allow creating a new stage from C++ code. Is that all this is needed for? If so then you can do that now by using MGlobal::executePythonCommand() and import and call the existing python script.

@frohnej-adsk
Copy link
Collaborator Author

frohnej-adsk commented May 5, 2023

Hi @seando-adsk , I was told a while ago that it would be preferable to reproduce what the Python script is doing in C++. However, we can definitely challenge that.

The new C++ code allows for:

  1. Creating stages from within the C++ code. This could also be done now by using the existing Python script and MGlobal::executePythonCommand().
  2. Creating stages deep in the Maya hierarchy. This could probably be done by modifying the existing Python script and using MGlobal::executePythonCommand().
  3. Wrapping stage creation into an Ufe::UndoableCommand so that it can be undone by UFE clients. I'm not sure if this is possible with MGlobal::executePythonCommand(). According to my current understanding, MGlobal::executePythonCommand() will add an item to the Maya undo queue directly. A Ufe::UndoableCommand on the other hand can be undone by Ufe::UndoableCommand::undo() and can be added to the Maya undo queue manually if desired.

These three points are required for a UFE interface I'm working on.

Is it possible to wrap MGlobal::executePythonCommand() in an Ufe::UndoableCommand? If so, we could consider calling the existing Python script (and modify it to allow for point 2). If not, I think it's necessary to go through C++.

Copy link
Collaborator

@seando-adsk seando-adsk left a comment

Choose a reason for hiding this comment

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

Overall the changes are good. The ability to create the stage anywhere in Maya hier is nice.
But the execute() method needs to be reworked.

@frohnej-adsk
Copy link
Collaborator Author

Rebase on dev to fix formating.

seando-adsk
seando-adsk previously approved these changes May 30, 2023
Comment on lines 253 to 255
if (!parent) {
return "";
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this check? Your create() method below and checks for and returns nullptr if input parent is empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, see 3e744ca.

lib/mayaUsd/ufe/UsdUndoCreateStageWithNewLayerCommand.cpp Outdated Show resolved Hide resolved
@seando-adsk seando-adsk added adsk Related to Autodesk plugin ufe-usd Related to UFE-USD plugin in Maya-Usd labels May 30, 2023
Add an undoable command that creates a stage with a new layer.

The new command is a C++ implementation of the existing mayaUsd_createStageWithNewLayer.py Python script. The C++ command will:
- enable the creation of stages from within the C++ code.
- enable the creation of stages deep in the Maya hierarchy.
- wrap stage creation into an Ufe::UndoableCommand so that it can be undone by UFE clients.

This commit also adds a Python binding for the stage creation command, which is used in mayaUsd_createStageWithNewLayer.py to replace the current implementation.
@frohnej-adsk frohnej-adsk force-pushed the frohnej/MAYA-129059/createStageCommand branch from 3e744ca to 7a0ee45 Compare May 30, 2023 15:46
@frohnej-adsk
Copy link
Collaborator Author

Squash commits for a clean history.

@frohnej-adsk frohnej-adsk added the ready-for-merge Development process is finished, PR is ready for merge label May 30, 2023
@seando-adsk seando-adsk merged commit 59b642c into dev May 31, 2023
@seando-adsk seando-adsk deleted the frohnej/MAYA-129059/createStageCommand branch May 31, 2023 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adsk Related to Autodesk plugin 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.

5 participants