View Full Version : Question regarding set attribute "doubleArray"

11 November 2012, 09:15 AM
Hi guys,

I need a help to sort out.
I did a test to add an attribute of type doubleArray, and then assign values to it.
But I got an unexpected result in MEL version, while got a correct one in python/ pymel
below are the MEL version

// MEL
createNode null -n "myNode";
addAttr -ln "value" -dt doubleArray;
setAttr "myNode.value" -type doubleArray 1.0 2.1 3.1;
print `getAttr myNode.value`;

// Result:
// Warning: Unrecognized node type 'null'; preserving node information during this session. //
// 2.1

The result output only 1 number instead of 3.
Later, I tried to change the 3rd line to setAttr "myNode.value" -type doubleArray 2.0 2.1 3.1;
and run the 4th line again, and the result turned to...

// Result:
// 2.1
// 3.1

As showed above, the 1st value I gave was always ignored for unknown reason, and the rest ones were correctly output as long as the 1st value is >= 2.0.

Lastly, I did same thing in python/ pymel, and it output as my expectation.

## python/ pymel
from pymel.core import *
import maya.cmds as mc
mc.createNode( 'null', n='myNode')
mc.addAttr( longName='value', dt='doubleArray' )
PyNode('myNode').value.set( [1.0, 1.1, 1.2] )
print PyNode('myNode').value.get()

// Result:
// [1.0, 1.1000000000000001, 1.2]

Could anyone do me a favor to explain what's going on with my 3 test? Thanks!


11 November 2012, 11:57 AM
In MEL you need to specify the number of values for your array first, so the command looks like
setAttr "myNode.value" -type doubleArray 3 1.0 2.1 3.1;

CGTalk Moderation
11 November 2012, 11:57 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.