Home Coding, Scripting, Shaders

Mel script - Repeat current poly reduce function on all selected objects?

jt_knight
polycounter lvl 2
Offline / Send Message
jt_knight polycounter lvl 2

I'm looping through multiple objects, but the loop stops before going to the next object.

Created a loop with condition. If condition is met, it calls a ReduceEdge() function. Problem is it will only iterate once and not go to the next object and repeat the procedure.

  1. global proc ReduceEdge()
  2. {
  3. polySelectEdgesEveryN "edgeRing" 2;
  4. polySelectEdgesEveryN "edgeLoop" 1;
  5. polyDelEdge -cv on;
  6. }
  7.  
  8. string $newSel[] = `ls -sl`;
  9.  
  10. for($i = 0; $i < size($newSel); $i++)
  11. {
  12. select $newSel[$i];
  13. int $polyEval[] = `polyEvaluate -e $newSel[$i]`;
  14. int $temp = $polyEval[0];
  15.  
  16. for($k = 0; $k < $temp; $k++)
  17. {
  18. string $polyInfo[] = `polyInfo -fn ($newSel[$i] + ".f[" + $k + "]")`;
  19. $polyInfo = stringToStringArray($polyInfo[$i]," ");
  20.  
  21. float $vPosX = $polyInfo[2];
  22. float $vPosY = $polyInfo[3];
  23. float $vPosZ = $polyInfo[4];
  24.  
  25. if($vPosX == 0 && $vPosY == 0 && $vPosZ == 1.0)
  26. {
  27. select ($newSel[$i] + ".e[" + $k + "]");
  28. ReduceEdge();
  29. }
  30. }
  31. }

Expected results: If I select 4 cylinders, all their edges will reduce by half the current amount.

Actual results: 
When 4 cylinders are selected, only one reduces down to half the edges. The rest stay the same.

Replies

Sign In or Register to comment.