From 3c8307ef54c8a216da8ea115c93acf4612a353ff Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Fri, 14 Jul 2023 14:11:15 -0400 Subject: [PATCH] EMSUSD-261 fix root layer attribute in AE - Add dependencies between file path attribute and the root layer, session layer and prim path attributes. - Add a sript job to update the root layer and prim field in teh AE when the file path changes. --- lib/mayaUsd/nodes/proxyShapeBase.cpp | 7 +++++++ .../AEmayaUsdProxyShapeBaseTemplate.mel | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/mayaUsd/nodes/proxyShapeBase.cpp b/lib/mayaUsd/nodes/proxyShapeBase.cpp index 522d0ff7da..623fcbca0f 100644 --- a/lib/mayaUsd/nodes/proxyShapeBase.cpp +++ b/lib/mayaUsd/nodes/proxyShapeBase.cpp @@ -467,6 +467,13 @@ MStatus MayaUsdProxyShapeBase::initialize() retValue = attributeAffects(filePathAttr, outStageDataAttr); CHECK_MSTATUS_AND_RETURN_IT(retValue); retValue = attributeAffects(filePathAttr, outStageCacheIdAttr); + CHECK_MSTATUS_AND_RETURN_IT(retValue); + retValue = attributeAffects(filePathAttr, rootLayerNameAttr); + CHECK_MSTATUS_AND_RETURN_IT(retValue); + retValue = attributeAffects(filePathAttr, sessionLayerNameAttr); + CHECK_MSTATUS_AND_RETURN_IT(retValue); + retValue = attributeAffects(filePathAttr, primPathAttr); + CHECK_MSTATUS_AND_RETURN_IT(retValue); retValue = attributeAffects(primPathAttr, outStageDataAttr); CHECK_MSTATUS_AND_RETURN_IT(retValue); diff --git a/plugin/adsk/scripts/AEmayaUsdProxyShapeBaseTemplate.mel b/plugin/adsk/scripts/AEmayaUsdProxyShapeBaseTemplate.mel index 852013a617..24a869684a 100644 --- a/plugin/adsk/scripts/AEmayaUsdProxyShapeBaseTemplate.mel +++ b/plugin/adsk/scripts/AEmayaUsdProxyShapeBaseTemplate.mel @@ -11,7 +11,7 @@ global proc AEmayaUsdProxyShapeInfoNew(string $input) AEmayaUsdProxyShapeInfoReplace($input); } -global proc AEmayaUsdProxyShapeInfoReplace(string $input) +global proc string AEmayaUsdProxyShapeInfoChanged(string $input) { // From the input attribute we simply want the node name. string $nodeName = plugNode($input); @@ -24,6 +24,22 @@ global proc AEmayaUsdProxyShapeInfoReplace(string $input) textFieldGrp -edit -text $rootLayer mayaUsdProxyShapeRootLayer; textFieldGrp -edit -text $defaultPrim mayaUsdProxyShapeDefaultPrim; + + return $fullNodeName; +} + +global proc AEmayaUsdProxyShapeInfoReplace(string $input) +{ + string $fullNodeName = AEmayaUsdProxyShapeInfoChanged($input); + + // Add a script job on the file path attribute so we can update the AE control + // if the attribute changes from the outside. + global int $mayaUsdProxyShapeInfoScriptJobId = -1; + if (`scriptJob -exists $mayaUsdProxyShapeInfoScriptJobId`) + scriptJob -kill $mayaUsdProxyShapeInfoScriptJobId; + string $cmd = "AEmayaUsdProxyShapeInfoChanged(\"" + $input + "\")"; + string $attrName = $fullNodeName + ".filePath"; + $mayaUsdProxyShapeInfoScriptJobId = `scriptJob -parent mayaUsdProxyShapeRootLayer -attributeChange $attrName $cmd`; } global proc AEmayaUsdProxyShapeShareStageNew(string $shareStageAttr)