View Full Version : API: MRampAttribute Number of Entries
JoshM 05-18-2009, 03:31 PM Hey Guys,
I am using a MRampAttribute as a curve ramp in my plug-in, and everything works as expected. With one exception: I can only add 3 entries into the curve. In the initialization of my plug-in I automatically add 2 entries and everything works fine. When I create the node and edit the Curve Ramp by inserting another entry, it works fine as well. But when I try to add one more entry to the curve (a total of four) nothing happens but the last entry added snaps to this new position. I can't find anything in the API docs for adjusting this total number of entries for the Curve Ramp, so I am curious if anyone else has ran into this problem of having the Curve Ramp limiting the total number of entries to three?
Thanks in advance,
Josh
|
|
JoshM
05-18-2009, 05:52 PM
Another weird thing with this is that I can add more than three entries if I create the entry via MEL. For example:
setAttr myNode.myCurveRamp[3].myCurveRamp_FloatValue 0.75;
setAttr myNode.myCurveRamp[3].myCurveRamp_Position 0.25;
setAttr myNode.myCurveRamp[3].myCurveRamp_Interp 2;
Works without any problems. I have even tried setting MFnCompoundAttribute::setIndexMatters(true), which did not work. I know there is something that I am not setting correctly but I just can't find what it is.
Thanks in advance,
Josh
ticket01
05-19-2009, 05:50 AM
MFnCompoundAttribute? Could you show some code how you create the actual attribute in the initialize function? I guess you're not creating it correctly. There're the MRampAttribute::createColorRamp() or createCurveRamp() functions that you should use.
JoshM
05-19-2009, 08:27 PM
Thanks for responding. Here is the code I am using for the initialize():
MStatus myDeformNode::initialize(){
//attributes for myDeformNode
...
//falloff ramp attribute
MFnCompouondAttribute cAttr;
/*MObject*/ falloffGraph = cAttr.create("falloffGraph", "fog");
cAttr.setArray(true);
cAttr.setReadable(true);
//nested position attr of falloff graph
MObject oPosition = /*MFnNumericAttribute*/ nAttr.create("falloffGraph_Position", "fogp", MFnNumericData::kFloat);
nAttr.setReadable(true);
nAttr.setWritable(true);
nAttr.setKeyable(true);
//nested value attr of falloff graph
MObject oFloatValue = nAttr.create("falloffGraph_FloatValue", "fogp", MFnNumericData::kFloat);
nAttr.setReadable(true);
nAttr.setWritable(true);
nAttr.setKeyable(true);
//nested enum attr of falloff graph
MObject oEnumValue = /*MFnEnumAttribute*/ eAttr.create("falloffGraph_Interp", "fogi");
eAttr.addField("None", 0);
eAttr.addField("Linear", 1);
eAttr.addField("Smooth", 2);
eAttr.addField("Spline", 3);
eAttr.setReadable(true);
eAttr.setWritable(true);
eAttr.setKeyable(true);
cAttr.addChild(oPosition);
cAttr.addChild(oFloatValue);
cAttr.addChild(oEnumValue);
}
After switching the code to the following:
MStatus myDeformNode::initialize(){
//attributes for myDeformNode
...
/*MObject*/ falloffGraph = MRampAttribute::createCurveRamp("falloffGraph", "fog", &stat);
}
everything is working as expected now. I can add as many entries to the ramp as I want =) Thanks for the help.
Josh
mfiorilli
09-07-2009, 04:54 AM
It's weird... I've been trying your code and many more examples about the ramp attributes but in the attribute editor, it gives me a button << Add new item >> and when I click on it, it adds these inputs to the node:
Curve Ramp[0] (FLOAT) (FLOAT) (FLOAT) (garbage icon)
Curve Ramp[1] (FLOAT) (FLOAT) (FLOAT) (garbage icon)
Curve Ramp[2] (FLOAT) (FLOAT) (FLOAT) (garbage icon)
Curve Ramp[...] (FLOAT) (FLOAT) (FLOAT) (garbage icon)
it's supposed to give a ramp graphic.. not this. I don't understand.
I'm using maya 2009
ticket01
09-07-2009, 06:18 AM
The feedback you get in the UI also depends on the AE Template. For a ramp attribute use:
AEaddRampControl "ATTRIBUTE_NAME";
mfiorilli
09-07-2009, 06:47 PM
Thanks for the quick answer :) I'm gonna try this out.
CGTalk Moderation
09-07-2009, 06:47 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.