-
Notifications
You must be signed in to change notification settings - Fork 202
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
Conversation
HamedSabri-adsk
commented
Jul 5, 2021
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 | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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.
@seando-adsk for Maya's side of changes see PR 19225 |
@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 |