// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== proc int checkContainerParents(string $container, string $containersToCheck[]) // // Return true if the container is a descendent member of any of the // containersToCheck. // { string $parentContainer = `container -q -findContainer $container`; while ($parentContainer != "") { if (stringArrayContains($parentContainer,$containersToCheck)) { return 1; } $parentContainer = `container -q -findContainer $parentContainer`; }; return 0; } global proc string[] findTransferValueTargets() // // Examine the current selection list to see if it indicates we should // do the "transfer attribute values" between 2 containers on the // selection list, or act on the sel list directly. // { string $sel[] = `ls -sl`; if (size($sel) > 2) { string $selCon[] = `ls -sl -containers`; if (size($selCon) == 2) { // if 2 containers are selected and the other selected // objects are members of those containers, then transfer values // on the containers // int $useContainers = 1; for ($selObj in $sel) { if (0 == `container -q -isContainer $selObj`) { if (! checkContainerParents($selObj,$selCon)) { $useContainers = 0; break; } } } if ($useContainers) { return $selCon; } } } return $sel; }