View Single Post
# 3 01-11-2008 , 03:19 AM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567
Hey, getting closer!

I have revised the latest piece of code on the locator's movement.

When the loop is done it now selects the end one so it's getting there, now instead of just selecting the end one how would I go about keeping each faceIndex selected, or at least put in an array, so I can select the array once the loop has finished.

I promise to stop with the annoying questions, for a little while at least ; ) , if I can get this to work lol.

for ($i=1;$i<5;$i++){
spaceLocator -n ("locator" + $i);
move (rand(-10,10)) 0 (rand(-10,10));

// create nearestPointOnMesh node
//string $nearestPoint = eval("createNode nearestPointOnMesh -n npom1");

string $nearestPoint = `createNode nearestPointOnMesh -n ("npom" + $i)`;

//connect it to the polymesh
connectAttr -f pPlane1.worldMesh ($nearestPoint + ".inMesh");

//connect locator1 pos' to nearestPointOnMesh pos'
connectAttr -f (("locator" + $i) + ".translateX") (("npom" + $i) + ".inPositionX");
connectAttr -f (("locator" + $i) + ".translateY") (("npom" + $i) + ".inPositionY");
connectAttr -f (("locator" + $i) + ".translateZ") (("npom" + $i) + ".inPositionZ");

//store face index
int $selFaces = `getAttr (("npom" + $i) + ".nearestFaceIndex")`;

select -add pPlane1.f[$selFaces];
}

Many thanks,

Chris