// =========================================================================== // 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. // =========================================================================== // // getNComponentToEdit // // Description: // This method returns the nComponent to edit based on the selected // nCloth object. // // Arguments: // $componentsOK: If true, it means that the calling operation can // operate on selected components of an nCloth. // If false, it means that the calling operation will only // operate on an nCloth selected as an object (not components). // global proc string getNComponentToEdit(int $componentsOK) { string $result = ""; // first get the nCloth related to the selection // string $meshAndCloth[]; $meshAndCloth = `getNMeshToPaint "" $componentsOK`; // now find the relevant constraint based on the selection // string $constraint = `getNConstraintToEdit "" 0`; if ("" != $constraint && size($meshAndCloth) > 0) { if (nodeType($constraint) == "transform") { string $constraintShape[] = `listRelatives -ni -path -type dynamicConstraint $constraint`; if (size($constraintShape) > 0) { $constraint = $constraintShape[0]; } } // now find the component on the constraint related to this shape // string $comp[] = `listConnections -type nComponent $constraint`; for ($nComp in $comp) { string $conns[] = `listConnections -shapes 1 -s 1 -d 0 ($nComp+".objectId")`; if (size($conns) > 0 && $conns[0] == $meshAndCloth[1]) { $result = $nComp; break; } } } return $result; }