Hi....
I am creating a MEL Script for Folding effect in Maya. But, the  problem is when the script runs the effect plays in hierarchy from 1st Parent to last child. I want this effect from last child to 1st parent. "HOW CAN I FIX MY PROBLEM"? My MEL script is given below.  

string $objs[] = ls -sl;
for ($i=0; $i<size($objs); $i++){

float $bbi[] = xform -q -a -ws -bb $objs[$i]  ;
float $avg =  (($bbi[0]+$bbi[3])/2) ;
float $a = (($bbi[1]+ $bbi[4])/2) ;
float $b = $bbi[2]  ;

xform -ws -piv $avg $a $b $objs[$i];

expression -s("int $speed = 10; float $rotation =  clamp(-180,180,((ctrl.A)*$speed));if($rotation == 180 || $rotation == -180) " + $objs[$i] + ".visibility = 0 ; else " + $objs[$i] + ".visibility = 1; " + $objs[$i] + ".rotateX = $rotation;") ;
parent  $objs[$i] $objs[$i+1];

}

PLS. HELP ME TO FIX THIS PROBLEM.......

  • created

    Aug '13
  • last reply

    Oct '13
  • 1

    reply

  • 1.4k

    views

  • 1

    user

1 month later

This seems to be in the wrong board. This should be moved to MEL.

Is this built for a specific scene, or are you wanting to use this on general scenes/selection as well?

If it's for a specific scene, I would just list the items in the order you want to fold them in an array.
ex:
string $objs[] = {"obj1","obj2","obj3"};

otherwise, I would recommend using a listRelatives command to get the full heirachy (research in the MEL reference) and go in reverse order

Let me know if this helps..

Suggested Topics

Want to read more? Browse other topics in Maya or view latest topics.