help with a highend3d mel script


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 

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];



Im new at this too but I would say just to start with you have to change all the CV stuff to vertices info…


you’re right, that is the first step. I did that and fortunately i’m not getting an error when I use the script on a poly surface, i’m just not getting the alignment that I was getting with the scripts for the nurbs cv’s. Still working on it, again, if anyone can help that would be great!!


Look up the filterExpand in the Maya help files.

the script reads…

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

that will return any of the selected cvs!

If you want it to work on poly verts you will have to use a diffrent filterExpand.

for example

string $parents[] = filterExpand -ex true -sm 31;

that will work on poly verts.



I guess I wasn’t too clear with my previous post. I’ve been guilty of stuff like that on occasion.

the filterExpand flag change from -sm 28 to -sm 31 is the one thing I already did in hopes of successfully editing it. And as I said, the script did indeed do something without giving me an error message. But the alignment of the poly points that resulted is not the same type of alignment that was the result of using the nurbs cv version of the script (which is the correct alignment I’m trying to emulate).

So, indeed that small change to the script was a viable change, but I’m still not getting the alignment that I need from the poly points. I think it has something to do with the step "define the plane by its normal ", and the last step “resolve the points onto the plane via the normal”. I don’t pretend to know enough about what’s going on with those parts of the script to be able to fix it right now.

Thanks for your help tho, and again, if anyone else can give some more direction, I would really appreciate it.


mmm, poly selectn list return, thats going to be it i suspects.
select some verts, do an ls -sl -flon them, and note that the returned order is not that which you selcted them by (its alpha#). so you have to do various slight-of-hands to determine the correct order. i use an undo method, which you can see in my poly-type scripts on highend3d, and discussed in some threads (im aka campbell). of particular interest will be a proc where someone consolidated the undo trick quite nicely … i think it might be posted on highend (~‘returnSelectnOrder’, or similar), else you’ll find it in the body of a thread there.

to be sure this is correct diagnosis, do a selectn w increasing indicies, so default return order is in agreement this time, and see that behaviour is-as-expected?

…i have a feeling there might be a plug for this on a|w, or highend? tho it might not be compiled for your current versn?


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.