Home Technical Talk

Maya Script for custom editing vertex normal

PetSto
polycounter lvl 4
Offline / Send Message
PetSto polycounter lvl 4
Hi, I had a script for Maya which copy direction from one vertex normal to another, but I can't find him now and don't remember his name or where I found him. This script was very simple, you need just select mesh, in marking menu, choose "vertex face", then select first vertex, from where you want copy normal direction and then selects the last vertex, where you want to copy new normal direction and then just run the script. Have you some ideas.

Thank you.



Replies

  • TTools
    Offline / Send Message
    TTools polycounter lvl 4
    I got you buddy :smile:

    Select any number of face vertices, the first being that which you want to copy from. Run the MEL script below. This will copy the normal direction from the first face vertex to all other selected.
    Code is commented so you can see what I'm doing to get there.  Hope this works for you :)


    //Enables selection order tracking
    selectPref -trackSelectionOrder true;
    //Store the selected face vertices.
    string $selected[] = `ls -sl -long -fl`;
    //If we don't have at least two selected bail out.
    if (size($selected) < 2 )
    {error "Please select at least two vertices!";}
    //Get the vertex normal orientation of the first selected face vert.
    float $vertFaceNormal[] = `polyNormalPerVertex -q -xyz $selected[0]`;
    //Assign the normal direction of the first face vert to all other face verts.
    for ($i = 1; $i < size($selected); $i++)
    {
        polyNormalPerVertex -x $vertFaceNormal[0] -y $vertFaceNormal[1] -z $vertFaceNormal[2] $selected[$i];
    }
  • PetSto
    Offline / Send Message
    PetSto polycounter lvl 4
    This script is exactly what I'm looking for, it's better than the original I had, thank you very much Thomas, I really appreciate it.  :)
  • TTools
    Offline / Send Message
    TTools polycounter lvl 4
Sign In or Register to comment.