FORUMS: list search recent posts

Mel Script does not work on All Selected Items

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>

Mohammad Taha
Mel Script does not work on All Selected Items
on Nov 16, 2015 at 11:16:05 am

Hello Everyone.
I'm Looking for a small advice.
I made a MEL Script what does couple of thinks to a selected object. Unfortunately if I select more then one and run the Script, It happens just to one Object.
I Tryed couple of changes, also with "for ($obj in $sel)" but somehow it doesn't work. I'm not this perfect with MEL scripting just started couple of month ago. So maybe someone can have a look and tell my what I'm doing wrong.
Thx alot.

proc extrudepoly()
{
float $edist = `textField -q -text edist`;
string $myobject[] = `ls -sl`;
print ("the quary name is" + $myobject[0]);
$item = $myobject[0] + ".f[0:999999]";
select -cl;
select -r $item;
ConvertSelectionToVertices;
polyMergeVertex -d 0.001 -ch 0;
ConvertSelectionToFaces;
select -r $item ;
polyExtrudeFacet -ch 1 -kft 1 -ltz $edist;
InvertSelection;
doDelete;
select -r $myobject[0];
DeleteHistory;

}
....


Return to posts index


Joel Benjamin
Re: Mel Script does not work on All Selected Items
on Nov 18, 2015 at 4:45:20 pm

Hey Mohammad
It's tough to test directly because it seems to be referencing some UI whose code we don't have

But in general, if you want to have one or multiple objects selected, you could use a for loop

Something like this:


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

print ("There are " + size($args) + " objects selected.");

// you can use size to determine how many items in an array
int $howManyObjs = `size($args)`;


// a for loop to go through all the objects selected
for ($obj = 0; $obj<$howManyObjs; $obj++){

// temporality setting $edist
float $edist = .5;


// selecting the faces
$item = $args[$obj] + ".f[0:999999]";
select -cl;
select -r $item;
ConvertSelectionToVertices;
polyMergeVertex -d 0.001 -ch 0;
ConvertSelectionToFaces;
select -r $item ;
polyExtrudeFacet -ch 1 -kft 1 -ltz $edist;
InvertSelection;
doDelete;
select -r $args[$obj];
DeleteHistory;
}


Return to posts index


Mohammad Taha
Re: Mel Script does not work on All Selected Items
on Nov 19, 2015 at 6:26:47 am

Hi Joel,

Thanks.
I tryed with the loop funtcion but now i see my mistake. I finished now my scriped and can work with it. :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]