# Folding Effect In Maya

**URL:** https://forum.highend3d.com/t/folding-effect-in-maya/306
**Category:** Maya
**Tags:** mel
**Created:** [August 14, 2013, 1:12am UTC](https://forum.highend3d.com/t/folding-effect-in-maya/306 "2013-08-14T01:12:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![saurabh-srivastava](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@saurabh-srivastava](https://forum.highend3d.com/u/saurabh-srivastava)
#### Post date: [August 14, 2013, 1:12am UTC](https://forum.highend3d.com/t/folding-effect-in-maya/306/1 "2013-08-14T01:12:22Z")

</div>

Hi....  
I am creating a MEL Script for Folding effect in Maya. But, the&nbsp; 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. &nbsp;

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

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

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

expression -s("int $speed = 10; float $rotation =&nbsp; 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&nbsp; $objs[$i] $objs[$i+1];

}

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