// =========================================================================== // 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. // =========================================================================== // // // Description : // To snap together two sets of nurbs surface Cvs . Each set is picked // by doing a marquee select. // select nurbsSurface1.cv[0][0:6] nurbsSurface2.cv[0][0:6] // snapCvsToCvs // // Useful when attempting to snap boundary of one surfaces onto // another. // proc float[] worldPosition( string $comp[] ) // // Description : // { float $pos[] ; float $p[] ; int $i, $n ; $n = size($comp) ; for( $i = 0 ; $i < $n ; $i++ ) { string $item = $comp[$i] ; $p = `pointPosition -w $item` ; int $j = $i*3 ; $pos[$j] = $p[0] ; $pos[$j+1] = $p[1] ; $pos[$j+2] = $p[2] ; } return $pos ; } global proc int snapCvsToCvs() // // Description : // { int $i ; // 1. look at select list. Should have Two entries ! // string $list[] = `ls -sl` ; int $sz = size($list) ; if( $sz != 2 ) { error (uiRes("m_snapCvsToCvs.kErrorSelect2CVSets")) ; return 1 ; } // 2. Filter expand each of the two enteries. // global int $gSelectCVsBit ; string $slavecvs[] = `filterExpand -ex true -sm $gSelectCVsBit $list[0]` ; string $mastercvs[] = `filterExpand -ex true -sm $gSelectCVsBit $list[1]` ; // 3. After filter expand one should have identical #'s // int $ncv = size( $slavecvs ) ; if( $ncv != size($mastercvs) ) { error (uiRes("m_snapCvsToCvs.kErrorNeedSameNumOfCVs")); return 1 ; } // 4. get world pos's // float $slavecvp[] = worldPosition( $slavecvs ) ; float $mastercvp[] = worldPosition( $mastercvs ) ; // 5. Issue move cmds. // int $j = 0 ; for( $i = 0 ; $i < $ncv ; $i += 1, $j += 3 ) { float $x = $mastercvp[$j] - $slavecvp[$j] ; float $y = $mastercvp[$j+1] - $slavecvp[$j+1] ; float $z = $mastercvp[$j+2] - $slavecvp[$j+2] ; string $item = $slavecvs[$i] ; move -r $x $y $z $item ; } return 0; }