Home Technical Talk

Need help with a MEL script

Hi

 

I'm trying to use some MEL code to orient a EP curve control to a joint and while it puts the control in the correct orientation it offsets the control away from the joint. Why does this happen? The code is below:

___________________________________________________________________________________________

{
    string $sel[] = `ls -sl`;
    
    float $rotate[3] = `xform -q -ws -ro $sel[0]`;
    float $translate[3] = `xform -q -ws -t $sel[0]`;
    
    xform -ws -ro $rotate[0] $rotate[1] $rotate[2] $sel[1];
    xform -ws -t $translate[0] $translate[1] $translate[2] $sel[1];
    
}


The first image is how the code is supposed to work correctly: by orienting the control to the joint.

The second image is how the code works now: it offsets the control away from the joint.


Replies

  • sprunghunt
    Offline / Send Message
    sprunghunt polycounter
    instead of using this

     float $translate[3] = `xform -q -ws -t $sel[0]`;

    you should get the position of one of the pivots

    like this

     float $translate[3] = `xform -q -ws -rp $sel[0]`;

    the -rp bit stands for Rotate Pivot

    and instead of using the xform command to move the control to the pivot just use 

    $translate[0] $translate[1] $translate[2] $sel[1];move -ws 


  • Max_Animation
    Thanks for the reply man, but no joy, now I get an error message:

     Error: line 7: Invalid object or value: 90

    It seems to add 90 and -90 to the rotates of the EP curve object.

Sign In or Register to comment.