question about scripting with curves

question about scripting with curves

Anonymous
Not applicable
701 Views
2 Replies
Message 1 of 3

question about scripting with curves

Anonymous
Not applicable

Hi,

I'm fairly new to scripting MEL and I have a questions that I haven't been able to solve:

 

I need to create a curve with a certain number of points based on the size of my selection. Furthermore the points need to each have the position of each joint. So if I select 4 joints, it will create a curve with 4 points with the position in each joint etc.

 

Hope this makes sense?

0 Likes
Accepted solutions (1)
702 Views
2 Replies
Replies (2)
Message 2 of 3

tdHendrix
Collaborator
Collaborator
Accepted solution

Hello, the following should do what you want:

 

proc string create_crv_on_objects(string $objects[])
{
    float $first_pos[] = `xform -q -ws -rp $objects[0]`;
    string $crv = `curve -p $first_pos[0] $first_pos[1] $first_pos[2]`;
    
    for ($i=1; $i<size($objects); $i++)
    {
        float $pos[] = `xform -q -ws -t $objects[$i]`;
        curve -append -p $pos[0] $pos[1] $pos[2] $crv;
    }
    
    return $crv;
}

string $selected[] = `ls -sl`;

if (size($selected) > 0)
    create_crv_on_objects($selected);
else
    warning "Nothing is selected."

Greg Hendrix - Senior Technical Animator
LinkedIn : Twitter
Message 3 of 3

Anonymous
Not applicable

Thank you so much, this was exactly what I needed! 

0 Likes