Skip to content

Commit

Permalink
Merge pull request #3526 from Autodesk/bailp/EMSUSD-756/parent-under-…
Browse files Browse the repository at this point in the history
…stronger

EMSUSD-756 allow parenting under a stronger layer
  • Loading branch information
seando-adsk authored Dec 18, 2023
2 parents e23f505 + e22ad1c commit 2e7de5e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/usdUfe/ufe/UsdUndoInsertChildCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ UsdUndoInsertChildCommand::UsdUndoInsertChildCommand(

// Apply restriction rules
UsdUfe::applyCommandRestriction(childPrim, "reparent");
UsdUfe::applyCommandRestriction(parentPrim, "reparent");
// Note: the parent is only receiving the prim, so it can be declared
// in a weaker layer.
const bool allowStronger = true;
UsdUfe::applyCommandRestriction(parentPrim, "reparent", allowStronger);
}

UsdUndoInsertChildCommand::~UsdUndoInsertChildCommand() { }
Expand Down
31 changes: 31 additions & 0 deletions test/lib/ufe/testParentCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,37 @@ def testParentRestrictionDefaultPrim(self):
with self.assertRaises(RuntimeError):
cmds.parent(capsulePathStr, x1PathStr)

def testParentToStrongerLayer(self):
'''
Verify that parenting a prim to a prim defined in a lower layer
is permitted.
'''
cmds.file(new=True, force=True)

# Create an empty stage with a sub-layer
import mayaUsd_createStageWithNewLayer
proxyShapePathStr = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()
subLayer = usdUtils.addNewLayerToStage(stage)

# Create a xform in the sub-layer and a capsule in the root layer.
with Usd.EditContext(stage, subLayer):
subXFormName = '/SubXForm'
subXFormPrim = stage.DefinePrim(subXFormName, 'Xform')
self.assertTrue(subXFormPrim)

rootCapsuleName = '/RootCapsule'
rootCapsulePrim = stage.DefinePrim(rootCapsuleName, 'Capsule')
self.assertTrue(rootCapsulePrim)

subXFormUFEPath = proxyShapePathStr + "," + subXFormName
rootCapsuleUFEPath = proxyShapePathStr + "," + rootCapsuleName

cmds.parent(rootCapsuleUFEPath, subXFormUFEPath)

newRootCapsuleUSDPath = subXFormName + rootCapsuleName
self.assertTrue(stage.GetPrimAtPath(newRootCapsuleUSDPath))

@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.')
def testParentShader(self):
'''Shaders can only have NodeGraphs and Materials as parent.'''
Expand Down

0 comments on commit 2e7de5e

Please sign in to comment.