View Full Version : Mel script copyAttr question

03 March 2011, 03:46 AM
i'm so i'm trying to make my input2x = whatever my input1x is in my multiplyDivide node

how can i mel script this please.


03 March 2011, 08:26 AM
copyAttr command is for trasfering value, in-connections or out-connections from one node to another.

example from maya's Mel Reference
// transfer input connections and values from locator1 to locator2//copyAttr -inConnections -values locator1 locator2;// transfer only the translateX and translateY values//copyAttr -values -attribute tx -attribute translateY locator1 locator2;
but, I don't know what is your purpose of passing the value.
It can be done by using direct connect

connectAttr -force ("multiplyDivide1.input1X") ("multiplyDivide1.input2X");

or maybe by an expression

multiplyDivide1.input2X = multiplyDivide1.input1X;

03 March 2011, 03:08 PM

cheers bro

but I dont want the input1x and 2x connected
i just want to be able to
getAttr from input1x and
setAttr that result into input2x

even if i connect the attr and break connection after, it returns input2x value to default

i tired this....sorry my mel scripting isnt the worlds greatest =)
it didnt work

string $inputX = `getAttr multiplyDivide.input1X`;
setAttr multiplyDivide.input2X $inputX;

03 March 2011, 02:20 AM
string $inputX = `getAttr multiplyDivide.input1X`;
setAttr multiplyDivide.input2X $inputX;

The variable $inputX needs to be a float, bro.
Casting getAttr result to a string only works on an enum attribute by using -asString flag.

oh, and the copyAttr didn't work for your situation, cuz it will look for an attribute with the same name on the given node

ex: copyAttr -at input1x -at input2x multiplyDivide multiplyDivide;

it's gonna transfer value from input1x to input1x and 2x to 2x -so, nothing happens.

CGTalk Moderation
03 March 2011, 02:20 AM
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.