Question regarding addAttr/ getAttr for "doubleArray"

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 11 November 2012   #1
Question regarding addAttr/ getAttr for "doubleArray"

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!


Margirbee
 
Old 11 November 2012   #2
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:

addAttr -ln "threeDoubles -dt "doubleArray";

setAttr myNode.threeDoubles -type "doubleArray" 3 2.1 1.3 5.6;
 
Old 11 November 2012   #3
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:08 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.