View Full Version : Help with simple script

07 July 2012, 01:57 PM
Hi everyone,

I need a script that will do the following:

Combine two objects
Merge vertices with a threshold of 0.0050
Delete the objects history
Hide the new (selected) object

I can find all the individual commands in the script editor, for example the merge command is something like:

polyMergeVertex -d 0.005 -am 1 -ch 1 polySurface2728469;

but I don't know how to combine all the commands into one simlpe script and that it uses the selected object instead of a set name.

Any and all help is greatly appreciated :) I hope one of you Mel guru's can help me out as this would save me a LOT of time.


07 July 2012, 04:33 PM
wow.. you weren't kidding when you said simple.. ;)
This is so basic that practically everyone using Maya should be able to do this kind of stuff without too much effort!
// first, get the selected mesh objects:
string $sel[] = `ls -sl -dag -type "mesh" -ni`;
// now combine the first two:
string $result[] = `polyUnite $sel[0] $sel[1]`;
// next merge verts:
polyMergeVertex -d 0.005 $result[0];
// delete history:
delete -ch $result[0];
// finally hide it:
hide $result[0];

07 July 2012, 06:20 PM
Yea, I was pretty ashamed of myself having to ask tbh. But I just now of myself that I would spend more time figuring it all out with the proper syntax than asking someone here.

I thank you very much and this might just be my incentive to actually learn a bit of MEL.

Thanks again :)

CGTalk Moderation
07 July 2012, 06:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.