// =========================================================================== // 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 int lockIntersections() // // Description : // Select two or more curve param point or edit points // and lock these points together to ensure an intersection. // NOTE: Works of the selection list. // { string $curveNames[] ; string $locators[] ; string $lsqNodes[] ; int $len ; int $i ; int $ok = 1 ; int $sc = 0 ; $curveNames = `ls -sl` ; $len = size($curveNames) ; if( $len == 0 ) return 0 ; // run filter to get only items of interest. // global int $gSelectEditPointsBit ; global int $gSelectCurveParmPointsBit ; $curveNames = `filterExpand -ex true -sm $gSelectEditPointsBit -sm $gSelectCurveParmPointsBit $curveNames`; $len = size($curveNames) ; if( $len == 0 ) return 0 ; if( $ok ) { for( $i = 0 ; $i < $len ; $i++ ) { string $name = $curveNames[$i] ; string $tmpResults[] ; if( catch( $tmpResults = `pointCurveConstraint -ch 1 -rpo 1 $name` ) ) { $ok = 0 ; $sc = 1 ; } else { $locators[$i] = $tmpResults[0] ; $lsqNodes[$i] = $tmpResults[1] ; } } } // // Disconnect all locators but locator [0]. // locator[0].wp[0] now fans out to all other nodes. // That way we have one locator controlling the position // of the intersection point. // string $inAttr ; if( $ok ) { $len = size($locators) ; string $newSrc = $locators[0] + ".wp[0]" ; for( $i = 1 ; $i < $len ; $i++ ) { string $dests[] ; string $locName = $locators[$i] ; $inAttr = $locName + ".wp[0]" ; $dests = `listConnections -p true $inAttr` ; if( size($dests) > 0 ) { disconnectAttr $inAttr $dests[0] ; connectAttr $newSrc $dests[0] ; } delete $locName ; } select -r $locators[0] ; } if( $ok != 1 ) $sc = $ok ; return $sc ; }