View Full Version : Using variables for a type: double3

12 December 2012, 12:32 PM
My question is regarding this code:
float $red[] = {1.0 , 0.0 , 0.0};
setAttr ($lol+".color") -type double3 $red[0] $red[1] $red[2];
Isn't there a better way to write a variable into that double?
$red[0] $red[1] $red[2] looks so ugly

12 December 2012, 01:24 PM
At least you can omit "-type double3".

12 December 2012, 01:41 PM
totally agree, that's why in the Red9 MetaClass wrapper I've allowed you to just set double3's as node.color=(1.0,1.0,1.0) you can also now add them in this with r9Meta.addAttr('attrName',attrType='double3',value=(1.0,1.0,1.0))
and that'll add it, set the child attrs, and set the value in one go


12 December 2012, 03:44 PM
Sure there's a way, it's called python:

red = [1.0 , 0.0 , 0.0];
mc.setAttr("lambert1.color", red);

More info:


12 December 2012, 03:59 PM
actually you still can't set double3's like that... you still have to set the 3 values as you would in mel

12 December 2012, 04:05 PM
Hmm, sorry, my mc is set by default ( to:

import pymel.core as mc

(my bad - against convention)

So I take these things for granted.

12 December 2012, 05:27 PM
Or the OP writes his own substitute function for 'setAttr' for the sake of laziness:

global proc setAttrLazy(string $objAttr, float $value[])

CGTalk Moderation
12 December 2012, 05:27 PM
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.