// =========================================================================== // 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. // =========================================================================== // FILE: AElatticeRelated.mel // INPUT: string (node name) // RETURN: string[] (list of related nodes, with the node whose // tab you want to be opened duplicated at the // end of the array) // global proc string[] AElatticeRelated (string $node) { string $preferredNode = ""; string $retval[]; int $ii, $jj; string $siblings[] = `listRelatives $node`; string $origNode = ""; string $flexorNode = ""; // get the siblings which will include a flexor shape if // it is a flexor and a non history lattice if it has history // int $len = size($siblings); for ($ii = 0; $ii < $len; $ii++) { string $currSib = $siblings[$ii]; if ("flexorShape" == nodeType($currSib)) { $flexorNode = $currSib; } if ("lattice" == nodeType($currSib)) { string $hist[] = `listHistory $currSib`; if (size($hist) == 0) { $origNode = $currSib; } } } if ($origNode != "") { $retval[size($retval)] = $origNode; } if ($flexorNode != "") { $retval[size($retval)] = $flexorNode; } // look for a connected ffd node // string $conns[2] = `listConnections -s false ($node+".latticeOutput")`; $len = size($conns); for ($ii = 0; $ii < $len; $ii++) { if ("ffd" == nodeType($conns[$ii]) || "jointFfd" == nodeType($conns[$ii])) { $retval[size($retval)] = $conns[$ii]; // see if there is a locator on the sculpt // $conns = `listHistory ($conns[$ii]+".baseLatticeMatrix")`; int $len = size($conns); for ($ii = 0; $ii < $len; $ii++) { if ("baseLattice" == nodeType($conns[$ii])) { string $parents[] = `listRelatives -p ($conns[$ii])`; if (size($parents)) { $retval[size($retval)] = $parents[0]; } break; } } break; } } // we duplicate this node in the list so that it will be selected // if ($flexorNode != "") { $retval[size($retval)] = $flexorNode; } else if ($origNode != "") { $retval[size($retval)] = $origNode; } if (0 == size($retval)) { $retval[0] = $node; } return $retval; }