Hello All!!

I come to this forum of maya mel guru’s in hopes of a solution. I’m not the mel scripter I need to be so I am asking for your help.

I have found this script on highend3d that does exactly what I want it to do, except for the fact that it only works with nurbs cv’s. I need the script to do what it is supposed to do, but do it with poly points. Can anyone point me in the right direction in terms of what I need to do to edit this script so that it works with poly points instead of nurbs cv’s? Thanks in advance for any help y’all can give.

I hope this isn’t too inappropriate to post this script here, if it is please let me know and I’ll find a more appropriate means of getting an answer to my inquiry.

// Select three CVs first as pins

// any other cvs selected after the first two will be moved

// onto the plane defined by the pins

// useful for smoothing corners where patches meet

// by Matthew Gidney 2000

//

global proc mPlanarCvs() {

string $parents[] = `filterExpand -ex true -sm 28`

;

int $numberOfCvs = `size $parents`

;

```
if ( $numberOfCvs < 4) {
print("mPlanarCvs(): You must pick at least 4 Cv's to align
```

");

return;

}

float $CVPin1[3] = `xform -q -worldSpace -t $parents[0]`

;

float $CVPin2[3] = `xform -q -worldSpace -t $parents[1]`

;

float $CVPin3[3] = `xform -q -worldSpace -t $parents[2]`

;

```
// first define the plane by its normal
vector $pin1To2 = <<($CVPin1[0]-$CVPin2[0]),($CVPin1[1]-$CVPin2[1]),($CVPin1[2]-$CVPin2[2])>>;
vector $pin1To3 = <<($CVPin1[0]-$CVPin3[0]),($CVPin1[1]-$CVPin3[1]),($CVPin1[2]-$CVPin3[2])>>;
vector $normal = cross ($pin1To2,$pin1To3);
float $magNormal = mag ($normal);
vector $unitNormal = unit ($normal);
// next resolve the points onto the plane via the normal
for ($cnt = 3; $cnt < ($numberOfCvs); $cnt++) {
float $point[3] = `xform -q -worldSpace -t $parents[$cnt]`;
vector $pointToPin1 = <<($point[0]-$CVPin1[0]),($point[1]-$CVPin1[1]),($point[2]-$CVPin1[2])>>;
float $magPointToPin1 = mag ($pointToPin1);
float $dotProduct = dot ( $normal,$pointToPin1);
vector $moveVectorRel = -1.0 * $unitNormal * ($dotProduct / $magNormal);
xform -worldSpace -r -t ($moveVectorRel.x) ($moveVectorRel.y) ($moveVectorRel.z) $parents[$cnt];
}
```

}