C++ api issue

33 views
Skip to first unread message

Todd Widup

unread,
Jun 25, 2021, 12:53:01 AMJun 25
to python_in...@googlegroups.com
MStatus ArsenalPoseManager2::initialize()
{
MStatus status;
MFnNumericAttribute nAttr;
MFnMatrixAttribute mAttr;
MFnMessageAttribute meAttr;
MFnTypedAttribute tAttr;
MFnCompoundAttribute cmpAttr;

dataFile = tAttr.create("PoseFile", "psf", MFnData::kString);
tAttr.setInternal(true);
tAttr.setUsedAsFilename(true);
tAttr.setStorable(true);
tAttr.setKeyable(false);
addAttribute(dataFile);

poseDriver = meAttr.create("poseDriver", "pd");
meAttr.setArray(false);
meAttr.setStorable(true);
meAttr.setKeyable(false);
addAttribute(poseDriver);

poseDriverValue = nAttr.create("poseAttribute", "pa", MFnNumericData::kFloat);
nAttr.setArray(false);
nAttr.setStorable(true);
nAttr.setKeyable(true);
addAttribute(poseDriverValue);

poseName = tAttr.create("poseName", "pn", MFnData::kString);
tAttr.setArray(false);
tAttr.setStorable(true);
tAttr.setKeyable(false);
addAttribute(poseName);

poseNode = meAttr.create("poseNode", "pnd");
meAttr.setArray(false);
meAttr.setStorable(true);
meAttr.setKeyable(false);
addAttribute(poseNode);

poseMatrix = mAttr.create("poseMatrix", "pm", MFnMatrixAttribute::kDouble);
mAttr.setArray(false);
mAttr.setStorable(true);
mAttr.setKeyable(true);
addAttribute(poseMatrix);

poseSets = cmpAttr.create("poseSet", "ps");
cmpAttr.setArray(true);
cmpAttr.addChild(poseNode);
cmpAttr.addChild(poseMatrix);
cmpAttr.setReadable(true);
cmpAttr.setUsesArrayDataBuilder(false);
addAttribute(poseSets);

poseData = cmpAttr.create("poseData", "pd");
cmpAttr.setArray(true);
cmpAttr.addChild(poseDriver);
cmpAttr.addChild(poseDriver);
cmpAttr.addChild(poseName);
cmpAttr.addChild(poseSets);
cmpAttr.setReadable(true);
cmpAttr.setUsesArrayDataBuilder(false);
addAttribute(poseData);

return MS::kSuccess;
}


that was working on the build I did the other day, but all of a sudden its not adding the compound attribute, no error or anything just not there.  Any thoughts as to why?


--
Todd Widup
Creature TD / Technical Artist
todd....@gmail.com

Marcus Ottosson

unread,
Jun 25, 2021, 1:41:31 AMJun 25
to python_in...@googlegroups.com

Looks like poseDriver is added twice.

    cmpAttr.addChild(poseDriver);
    cmpAttr.addChild(poseDriver);

Don’t forget to check the status after each call. It’ll tell you when any of them fails, which in this case is likely the second call to adding poseDriver.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABBPk36ThRdY1qiR_6JU4JY3%3DH--LVqqtc9ZYHAfu6X15iH%2BCA%40mail.gmail.com.

Todd Widup

unread,
Jun 25, 2021, 2:22:31 PMJun 25
to python_in...@googlegroups.com
caught that last night and fixed it, still dont get the compound

Todd Widup

unread,
Jun 25, 2021, 4:31:34 PMJun 25
to python_in...@googlegroups.com
so tracked it to the compound, its failing to add it..thanks for the pointer Marcus, not to track down what is causing the fail

Chad Vernon

unread,
Jun 26, 2021, 12:54:21 AMJun 26
to Python Programming for Autodesk Maya
You don't need to addAttribute on attributes added to a compound. Once you add the compound, it will add the children. Attributes are also storable and readable by default so you don't need to explicitly set them so. Attributes are also not keyable by default.

I'm not sure if it makes sense to have a matrix attribute be keyable.

It could also be the short name is already taken by some other attribute, which is why I usually just use the long name as the short name.

Reply all
Reply to author
Forward
0 new messages