mayaUser2011
01-15-2011, 04:51 AM
I am trying to create an attribute which is an array of array, and the number of elements are set at runtime. What I'm trying to store is an array of vertices, and at each index are multiple lists of angles, corresponding to the shapes affecting it.
I have set it up as : (I don't know if i'm missing something here)
jointAngles = tAttr.create("joints", "jts", MFnData::kDoubleArray);
tAttr.setStorable(true);
tAttr.setConnectable(true);
tAttr.setReadable(true);
tAttr.setWritable(true);
tAttr.setHidden(false);
cAttr.setArray(true);
tAttr.setUsesArrayDataBuilder(true);
// this is the compound attribute
vertices= cAttr.create("vertices", "vts");
cAttr.addChild(jointAngles);
cAttr.setStorable(true);
cAttr.setConnectable(true);
cAttr.setReadable(true);
cAttr.setWritable(true);
cAttr.setHidden(false);
cAttr.setArray(true);
cAttr.setUsesArrayDataBuilder(true);
addAttribute(THISCLASS::vertices);
Now when I try to access the data and set it up,
MObject obj;
MFnDoubleArrayData arr;
obj = arr.create(myArray, &stat);
MPlug parent = P.elementByLogicalIndex(vertex_index, &stat);
// for every shape there will be a list of joint angles
MPlug child = parent.child(0,&stat);
child.setValue(obj);
This sets the first shape's angles, when i try to access child at 1,2,3 etc it crashes, because there is no child there. And everytime this runs(per shape), it overwrites the data, how do I add multiple shapes at the child level ? i.e. multiple joint arrays under the child joint....
any help is appreciated, thanks !
I have set it up as : (I don't know if i'm missing something here)
jointAngles = tAttr.create("joints", "jts", MFnData::kDoubleArray);
tAttr.setStorable(true);
tAttr.setConnectable(true);
tAttr.setReadable(true);
tAttr.setWritable(true);
tAttr.setHidden(false);
cAttr.setArray(true);
tAttr.setUsesArrayDataBuilder(true);
// this is the compound attribute
vertices= cAttr.create("vertices", "vts");
cAttr.addChild(jointAngles);
cAttr.setStorable(true);
cAttr.setConnectable(true);
cAttr.setReadable(true);
cAttr.setWritable(true);
cAttr.setHidden(false);
cAttr.setArray(true);
cAttr.setUsesArrayDataBuilder(true);
addAttribute(THISCLASS::vertices);
Now when I try to access the data and set it up,
MObject obj;
MFnDoubleArrayData arr;
obj = arr.create(myArray, &stat);
MPlug parent = P.elementByLogicalIndex(vertex_index, &stat);
// for every shape there will be a list of joint angles
MPlug child = parent.child(0,&stat);
child.setValue(obj);
This sets the first shape's angles, when i try to access child at 1,2,3 etc it crashes, because there is no child there. And everytime this runs(per shape), it overwrites the data, how do I add multiple shapes at the child level ? i.e. multiple joint arrays under the child joint....
any help is appreciated, thanks !
