// =========================================================================== // 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. // =========================================================================== global proc string[] getNMeshToPaint( string $useThisMesh, int $componentsOK ) // // Description: // Get the mesh to be painted. // Arguments: // $useThisMesh: If "", then get the mesh from the selection, else // use the supplied mesh. // $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). // { string $mSel[]; if( $useThisMesh == "" ){ // First, list all the meshes selected // $mSel = `ls -sl -dag -type mesh -visible -noIntermediate`; if (size($mSel) == 0 && $componentsOK) { string $sel[] = `ls -sl -visible -noIntermediate`; for ($item in $sel) { string $buf[]; if (tokenize($item,".",$buf) > 1) { string $isMesh[] = `ls -lf -dag -type mesh $buf[0]`; if (size($isMesh) && !stringArrayContains($buf[0],$mSel)) { $mSel[size($mSel)] = $buf[0]; } } } } } else { $mSel[0] = $useThisMesh; } // Search for a unique nucleus mesh // string $retval[]; int $index = 0; int $numSel = size($mSel); string $mesh; string $cloth; while( $index < $numSel ){ string $meshSel = $mSel[$index]; $cloth = findTypeInHistory( $meshSel, "nBase", 1,1 ); if( $cloth != "" ){ if( $mesh != "" ){ // We had previously found one, bail // warning((uiRes("m_getNMeshToPaint.kNClothPaintMultiWarn"))); clear $retval; break; } else { $mesh = $meshSel; $retval[0] = $mesh; $retval[1] = $cloth; } } $index++; } return $retval; }