PDA

View Full Version : CompoundAttribute and setArray


atap3d
01-16-2009, 10:24 AM
Hi
I'm trying to write maya node
I have a very simple code

MStatus myMayaTest::initialize()
{
............
MFnTypedAttribute strAttr;
str = strAttr.create("str", "s", MFnData::kString, &stat);
strAttr.setStorable(true);

MFnNumericAttribute numAttr;
dig = numAttr.create("dig", "d", MFnNumericData::kDouble, 1.0, &stat);
numAttr.setStorable(true);

MFnCompoundAttribute cmpAttr;
grp = cmpAttr.create("grp", "g", &stat);
cmpAttr.setArray(true);
cmpAttr.addChild(str);
cmpAttr.addChild(dig);

addAttribute(grp);
............
}

after a successful compilation and creation node in Maya 2009, the attribute-editor looks like this
http://img440.imageshack.us/img440/2006/firstob5.jpg

after clicking "Add New Item" button Maya reported error
http://img174.imageshack.us/img174/4972/thridwv5.jpg
http://img174.imageshack.us/img174/2219/secondil3.jpg

I try to comment string cmpAttr.setArray(true); and compile source.

MStatus myMayaTest::initialize()
{
............
//cmpAttr.setArray(true);
............
}

my node looks like this
http://img66.imageshack.us/img66/8875/78107935tx4.jpg

it is impossible to enter anything in "dig"

I checked it in Leopard and Windows

after a successful compilation and creation node in Maya 2008, the attribute-editor looks like this
http://img58.imageshack.us/img58/9797/63063568tv8.jpg

the "Add New Item" button successfully pressed, but the new attributes is gray. it is impossible to enter anything. And what is the "map" button?

Please help me to make a correct Array of CompoundAttribute with an opportunity to enter the parameters

Keilun
01-16-2009, 02:28 PM
Can we see your AEtemplate?

The first error of "Found no attribute match for: myMayaTest1.str" is pointing to some problems in your AEtemplate. In particular, str is a child of grp. So when you want to reference it, you now need to address it as:

myMayaTest1.grp[x].str

where x is the index of the compound attribute that you would like to query. I'm not sure why the UI elements are greyed out, but I'd guess we'd know more once we saw your AEtemplate code.

atap3d
01-16-2009, 05:05 PM
I dont have AEtemplate.
If problem in AEtemplate, why this error doesnt occur in maya 2008? Sources are identical.

Keilun
01-16-2009, 05:12 PM
How exactly are the "map" buttons being generated in your 2008 build? Those don't look default to me. At least I cannot recall those as default controls for compound array attr.

If you really don't have an AEtemplate, then that would point to a bug perhaps in the default AEtemplate code in 2009.

In any case, I would recommend creating your own AEtemplate to define the UI as you see fit. The default AEtemplate code will rarely give you the UI that you want (eg. the "dig" attribute probably won't expand properly unless you define your own UI template).

atap3d
01-21-2009, 05:09 PM
I compile this for macosx-maya2008. AEtemplate dont exist. Nothing changed. Gray attributes and map button. How can I ungray it with AEtemplate?
http://img89.imageshack.us/img89/2774/mayayk7.jpg

CGTalk Moderation
01-21-2009, 05:09 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.