// =========================================================================== // 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. // =========================================================================== // // // // // // reparentStrokes // // // None // // // This transfers all strokes on the first selected object to the second selected object. There should be exactly two objects selected and // both objects should be the same type: either nurbsSurface or mesh. One should first select the target and then the destination object, but if // only one object has strokes on it then the order does not matter. The toplogy need not match between the objects, but the uvs should match // if one wishes the strokes to transfer to matching positions. // // // None // // reparentStrokes // global proc reparentStrokes() { string $mSel[] = `ls -dag -sl -type mesh`; string $nSel[] = `ls -dag -sl -type nurbsSurface`; int $isPoly = false; string $source, $target; string $con,$type,$inCon; if( size($mSel) == 2 && size($nSel) == 0 ){ $isPoly = true; $source = $mSel[0]; $target = $mSel[1]; $con = ".worldMesh[0]"; $type = "curveFromMesh"; $inCon = ".inputMesh"; } else if( size($mSel) == 0 && size($nSel) == 2 ){ $source = $nSel[0]; $target = $nSel[1]; $con = ".worldSpace[0]"; $type = "curveFromSurface"; $inCon = ".inputSurface"; } else { error( (uiRes("m_reparentStrokes.kReparentSelection")) ); } string $crvs[]; $crvs= `listConnections -type $type ($source + $con)`; if( size($crvs) == 0 ){ $crvs = `listConnections -type $type ($target + $con)`; if( size($crvs) == 0 ){ error( (uiRes("m_reparentStrokes.kReparentNoStrokes"))); return; } else { string $tmp = $target; $target = $source; $source = $tmp; } } string $crv; for( $crv in $crvs ){ connectAttr -f ($target+$con) ($crv + $inCon); if( $isPoly ){ string $strokes[] = `listConnections -type stroke ($crv + ".outputCurve")`; if( size( $strokes ) > 0 ){ connectAttr -f ($target + ".uvSet[0].uvSetName") ($strokes[0] + ".uvSetName[0]"); } } } }