Setting compound attributes in Maya API

1,276 views
Skip to first unread message

marcin

unread,
Jan 11, 2012, 5:53:45 PM1/11/12
to maya_he3d
Hi!

I've problem with setting compound attribute in Maya API. I have a
node with following attributes:

MFnCompoundAttribute cAttr;
MFnTypedAttribute tAttr;

aMainChildArrayAttr = tAttr.create( "mainChildArrayAttr", "skp",
MFnPointArrayData::kPointArray);
tAttr.setStorable(true);
tAttr.setWritable(true);
tAttr.setReadable(true);

aMainChildAttr= cAttr.create("mainChildAttr", "mca");
cAttr.addChild(aMainChildArrayAttr);
cAttr.setArray(true);
cAttr.setReadable(true);
cAttr.setWritable(true);

aMainAttr = cAttr.create("mainAttr", "mnt");
cAttr.addChild(aMainChildAttr);
cAttr.setArray(true);
cAttr.setReadable(true);
cAttr.setWritable(true);

I've compound array attribute mainAttr (array) that have compound
attribute mainChildAttr (array). MainChildAttr is a compound attribute
for mainChildArrayAttr. I need MPxCommand that allow me to set those
attributes.
In Mel I can set this attributes using following command:

setAttr myNode.mainAttr[0].mainChildAttr[0].mainChildArrayAttr -type
pointArray 1 1 2 3 1

In MPxCommand I can set attributes using only MPlug, but I don't know
how can I set nested compound attributes using MPlug setValue method.
I can't use arrayBuilder because it's available only when creating
MPxNode. How I should set this attribute using API ? I think I can use
executeCommand with proper mel command in it, but maybe there's better
method to do this ?

Thanks in advance,
Marcin

j...@janberger.de

unread,
Jan 11, 2012, 6:34:00 PM1/11/12
to maya...@googlegroups.com

use MFnPointArrayData.create() to get an MObject, set the values using the MFnPointArrayData function set

and then set the MPlug with the MObject. 

 


marcin <majewsk...@gmail.com> hat am 11. Januar 2012 um 23:53 geschrieben:

marcin

unread,
Jan 18, 2012, 5:31:20 AM1/18/12
to maya_he3d


On Jan 12, 12:34 am, "j...@janberger.de" <j...@janberger.de> wrote:
> use MFnPointArrayData.create() to get an MObject, set the values using
> theMFnPointArrayDatafunction set
> and then set the MPlug with the MObject.

It works great! Thanks for help.

Marcin
Reply all
Reply to author
Forward
0 new messages