As you’re likely aware (because you all keep very up to date on everything related to me), I have used Houdini for the past two and a half years. I have been back to using Maya again since the summer. What have I learned in this time? Yes. That’s right. Maya is a piece of $%#&. Interpret that however you wish. For all you know, I could mean that it is a piece of gold. Yes… it could mean that.
Well, I decided to grab the reindeer by the reins and look a little more closely into MEL rather than just copying and pasting snippets from other people. I decided to try any make a bunch of parameters equal to the values in a bunch of other parameters. It doesn’t seem like Maya gives the user any easy way to do this. But why should it? Why would a user ever want to set a bunch of parameters to be equal to that of a bunch of other parameters? I miss you Houdini. I miss you very much.
Anyways, for those who are into sado machocism, here’s the MEL script:
string $copyobj = “pCube”;
string $pasteobj = “nurbsCylinder”;
$startnum = 1;
$endnum = 7;for ($i = $startnum; $i <= $endnum; $i++)
{connectAttr ($copyobj+$i+”.tx”) ($pasteobj+$i+”.tx”);
disconnectAttr ($copyobj+$i+”.tx”) ($pasteobj+$i+”.tx”);
connectAttr ($copyobj+$i+”.ty”) ($pasteobj+$i+”.ty”);
disconnectAttr ($copyobj+$i+”.ty”) ($pasteobj+$i+”.ty”);
connectAttr ($copyobj+$i+”.tz”) ($pasteobj+$i+”.tz”);
disconnectAttr ($copyobj+$i+”.tz”) ($pasteobj+$i+”.tz”);connectAttr ($copyobj+$i+”.rx”) ($pasteobj+$i+”.rx”);
disconnectAttr ($copyobj+$i+”.rx”) ($pasteobj+$i+”.rx”);
connectAttr ($copyobj+$i+”.ry”) ($pasteobj+$i+”.ry”);
disconnectAttr ($copyobj+$i+”.ry”) ($pasteobj+$i+”.ry”);
connectAttr ($copyobj+$i+”.rz”) ($pasteobj+$i+”.rz”);
disconnectAttr ($copyobj+$i+”.rz”) ($pasteobj+$i+”.rz”);};
3 thoughts on “I wrote my first MEL script today”
Comments are closed.
// Error: The source attribute 'pCube1.tx' cannot be found. //
$startnum = 1;
$endnum = 7;
for ($i = $startnum; $i <= $endnum; $i++)
{
string $copyobj[] = `polyCube`;
string $pasteobj[] = `cylinder`;
connectAttr ($copyobj[0]+".tx") ($pasteobj[0]+".tx");
}
JC
Sorry, I should have mentioned that this is assuming that you have created a poly cube and a poly cylinder and then duplicated them several times. The reason I tried creating the script is because I had to swap some geometry with new geometry after doing some cloth sims, so wanted to copy a bunch of parameters over to the new cloth objects from the old ones.
Thanks PZMan, that also seems to do the trick, but I guess you then need to keep the stuff that you're copying from since you're forming a connection.
I wish Maya were more procedural… in Houdini I'd simply swap out the geometry with new geometry and not need to worry about any animation or parameter values that were created down the road…