Assigning complex attribute to gradientControl


#1

Hi all,

Got an odd problem here when editing the -attribute flag on a gradientControl. According to the docs you can’t even change the attribute once the control is created, but I do it all the time and works fine - until now.

If I have a node with a ‘standard’ ramp-compatible compound attribute (in my case I used the MRampAttribute wrapper), changing the attribute after creation works as expected. However my ramp compound attribute is a part of a larger compound attribute which is also an array, so I would set it like this for example:

gradientControl -e -at myNode.arrayAttr[0].graphAttr

But Maya won’t let me assign it properly, nor does it throw an error message. If I assign it and then query the attribute property of the control, it returns nothing. But if I click on the graph control in the UI, it throws an error, using the example above, like this:

// Error: No object matches name: |transform1|myNode.arrayAttr[-1].graphAttr[0].graphAttr_FloatValue

Which is really weird because when I queried the attribute property of the control it returned nothing, but the error clearly showed it has saved the attribute just not the array index. Wrapping the attribute input in quotation marks doesn’t change it either.

The other simpler (non-compound) attributes in this array compound attribute behave as expected, so I don’t know whether it’s the gradientControl screwing up or having the ramp attribute inside an array compound attribute (or both) that’s making Maya mad.

By the way, this is being done in the context of a -callCustom in an AETemplate. I’d be happy with simply deleting the control and rebuilding it, but I don’t know how to insert it into the layout in it’s old position.

Any suggestions?


#2

I’m posting this as follow up, either I’m doing something very wrong or this is a bug in Maya (at least version 2009 Windows). I have exactly the same problem if I build the attrs in the initialize() function of a C++ plugin, or add the attrs manually via MEL.

As a simple example, this script creates a polySphere, adds a curve ramp to it and attaches the ramp to a widget.

window -title "Gradient Control For Attribute";
  columnLayout;
  	gradientControl -h 90 testGrad;
  showWindow;
  
  string $nodeName = `createNode polySphere`;
  	addAttr -ln "testGraph" -sn "tGp" -at compound -m -nc 3;
  		addAttr -ln "testGraph_Position" -sn "tGP" -at "float" -p "testGraph";
  		addAttr -ln "testGraph_FloatValue" -sn "tGF" -at "float" -p "testGraph";
  		addAttr -ln "testGraph_Interp" -sn "tGI" -at "enum" -enumName "0:1:2:3" -p "testGraph";
  
  setAttr ( $nodeName + ".testGraph[0].testGraph_FloatValue" ) 1.0;
  setAttr ( $nodeName + ".testGraph[0].testGraph_Position" ) 0.0;
  setAttr ( $nodeName + ".testGraph[0].testGraph_Interp" ) 3;
  
  gradientControl -e -at ( $nodeName + ".testGraph" ) testGrad;

This all works fine, but if I then embed the graph attr inside a multi compound attribute, even if it’s just a compound of one - it generates fine, until I try to add a point to the graph.

window -title "Gradient Control For Attribute";
  columnLayout;
  	gradientControl -h 90 testGrad;
  showWindow;
  
  string $nodeName = `createNode polySphere`;
  addAttr -ln "testContainer" -sn "tCn" -at compound -m -nc 1;
  	addAttr -ln "testGraph" -sn "tGp" -at compound -m -nc 3 -p "testContainer";
  		addAttr -ln "testGraph_Position" -sn "tGP" -at "float" -p "testGraph";
  		addAttr -ln "testGraph_FloatValue" -sn "tGF" -at "float" -p "testGraph";
  		addAttr -ln "testGraph_Interp" -sn "tGI" -at "enum" -enumName "0:1:2:3" -p "testGraph";
  
  setAttr ( $nodeName + ".testContainer[0].testGraph[0].testGraph_FloatValue" ) 1.0;
  setAttr ( $nodeName + ".testContainer[0].testGraph[0].testGraph_Position" ) 0.0;
  setAttr ( $nodeName + ".testContainer[0].testGraph[0].testGraph_Interp" ) 3;
  
  gradientControl -e -at ( $nodeName + ".testContainer[0].testGraph" ) testGrad;

The error being:

// Error: No object matches name: polySphere2.testContainer[-1].testGraph[1].testGraph_FloatValue // 

If anyone can tell me where I’m going wrong, or supply a workaround (I need the ability to store an indefinite amount of graphs in a node whilst still being compatible with the graph widget)?

Thanks.
Cam.


#3

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.