Select object one by one and do some operation on it?

Select object one by one and do some operation on it?

Anonymous
Not applicable
348 Views
4 Replies
Message 1 of 5

Select object one by one and do some operation on it?

Anonymous
Not applicable
I'm not familiar with MEL but i'm sure this is pretty easy and can takes me way less time than doing by hand this.

In my case I would select one object and do a combine on it (polyUnite). Then selecting the next one and so on...

The problem is that when I use MEL it select all the objects. Can you help me making it easier ?

Thank you !
0 Likes
349 Views
4 Replies
Replies (4)
Message 2 of 5

lee.dunham
Collaborator
Collaborator
you cant combine on just 1 object, so im abit confused.
can you provide an example?

as for looping and performing actions you typically use


string $mySel[] = `ls -sl` ;
for($sel in $mySel){
//do command on $sel
}
0 Likes
Message 3 of 5

Anonymous
Not applicable
To be more precise my objects are transform objects that have multiples shapes. (It's a CAD files I'm using).
To clean the multiple shapes into 1 shape and 1 object I need to combine it.
But I wish to keep the transform separate to each other so I don't combine 2 objects, only the shapes.

It results an error :
string $mySel[] = `ls -sl` ;
for($sel in $mySel){
polyUnite -ch 1 -mergeUVSets 1 $sel
};
// Error: }; //
// Error: Syntax error //
// Error: //
// Error: Syntax error //
0 Likes
Message 4 of 5

lee.dunham
Collaborator
Collaborator
this should work then.

string $mySel[] = `ls -sl` ;
for($sel in $mySel){
// get shapes of object
string $children[] = `listRelatives -s -fullPath $sel` ;
// combine and store new objects
string $newObject[] = `polyUnite -ch 1 -mergeUVSets 1 $children` ;
// delete old transform node and rename new to old
delete $sel ;
rename $newObject $sel ;
}
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thank you for the tip !
It works wonderfully !

But the mesh generated miss something that I need to set a new shading group otherwise I only see the edges when I higlight it.

I seems like that it happen when I use the rename script. So I get rid over this part 🙂

Thank you so much 🙂

Can I ignore error message that make the script stops ? It happens because some of my objects don't have multiple shapes in it so it fails to combine and result as an error.
0 Likes