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-112372: Add restriction for grouping. #1550

Merged
merged 3 commits into from
Jul 7, 2021

Conversation

HamedSabri-adsk
Copy link
Contributor

group_blocking

@HamedSabri-adsk HamedSabri-adsk added workflows Related to in-context workflows ufe-usd Related to UFE-USD plugin in Maya-Usd labels Jul 5, 2021
Comment on lines +87 to 113
try {
auto newParentHierarchy = Ufe::Hierarchy::hierarchy(_group);
if (newParentHierarchy) {
for (auto child : _selection) {
auto parentCmd = newParentHierarchy->appendChildCmd(child);
parentCmd->execute();
append(parentCmd);
}
}
}

// Make sure to add the newly created _group (a.k.a parent) to selection. This matches native
// Maya behavior and also prevents the crash on grouping a prim twice.
Ufe::Selection groupSelect;
groupSelect.append(_group);
Ufe::GlobalSelection::get()->replaceWith(groupSelect);
// Make sure to add the newly created _group (a.k.a parent) to selection. This matches
// native Maya behavior and also prevents the crash on grouping a prim twice.
Ufe::Selection groupSelect;
groupSelect.append(_group);
Ufe::GlobalSelection::get()->replaceWith(groupSelect);

TF_VERIFY(
Ufe::GlobalSelection::get()->size() == 1,
"_group node should be in the global selection now. \n");
} catch (...) {
// undo previous AddNewPrimCommand
undo();

TF_VERIFY(
Ufe::GlobalSelection::get()->size() == 1,
"_group node should be in the global selection now. \n");
throw; // re-throw the same exception
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seando-adsk
Grouping in a two tier operation:

1- create a group node
2- insert selected item(s) under the group node.

There could be a case where creating a group node would be Ok by the restriction rules but not the insertion part.
For example, this scenario could happen if a user tries to group prim(s) in a layer other than the one where they were defined. In this case, the group creation itself will succeed but not the insertion part. In this case, we should throw an exception and undo the previous group command.

Also keep in mind that the way we are performing the insertion here makes it impossible to support grouping flags (e.g absolute, relative, etc...) . Eventually, the insertion logics needs to be moved in Maya so we can support those flags.

@HamedSabri-adsk
Copy link
Contributor Author

HamedSabri-adsk commented Jul 6, 2021

@seando-adsk for Maya's side of changes see PR 19225

@HamedSabri-adsk HamedSabri-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jul 7, 2021
@HamedSabri-adsk
Copy link
Contributor Author

@kxl-adsk I am marking this PR as ready to merge.

I ran the PF before and it all passed but one of the interactive fail which is not relevant here.

https://github.com/Autodesk/maya-usd/actions/runs/1006156994

@kxl-adsk kxl-adsk merged commit 2a40bbb into dev Jul 7, 2021
@kxl-adsk kxl-adsk deleted the sabrih/MAYA-112372/add_restriction_grouping branch July 7, 2021 22:13
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 workflows Related to in-context workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants