|11 November 2012||#1|
Los Angeles, USA
Join Date: Nov 2012
Question regarding addAttr/ getAttr for "doubleArray"
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
createNode null -n "myNode";
addAttr -ln "value" -dt doubleArray;
setAttr "myNode.value" -type doubleArray 1.0 2.1 3.1;
print `getAttr myNode.value`;
// Warning: Unrecognized node type 'null'; preserving node information during this session. //
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...
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] )
// [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||#2|
Join Date: Dec 2006
You should check out the syntax in the MEL documentation, particularly the examples written in the description of the setAttr command:
when setting attributes of type doubleArray, the first argument must be an integer defining how many elements the array will contain. It is then followed by the respective count of actual array-values you want to populate the attribute with.
Here's an example; I want to create an attribute to hold an array of three doubles:
aweControlPicker (GUI Picker for Maya)
|Thread Closed share thread|