Hey,
I am making a C++ plugin and I have a weird crash when using MRampAttributes.
I have an MPxNode, which has a child array of compound attributes.
When I try to add one or more ramp attributes as a child to this compound, Maya crashes when loading the plugin without providing a stack-trace in the Output window.
So the desired structure would be:
node.childCompoundArray[0].rampAttribute
Sometimes the plugin works with one ramp attribute added, but crashes when I add another one next to the first.
(node.childCompoundArray[0].rampAttributeB)
Any ideas why this may happen?
Does Maya prohibit using ramp attributes as child attributes / in an array?
Or can this be the fault of having multiple ramp attributes next to each other?
I have not found anything in the official documentation on this matter.
I am using the Maya 2019 API.
Thanks in advance,
Peter
Hey,
I am making a C++ plugin and I have a weird crash when using MRampAttributes.
I have an MPxNode, which has a child array of compound attributes.
When I try to add one or more ramp attributes as a child to this compound, Maya crashes when loading the plugin without providing a stack-trace in the Output window.
So the desired structure would be:
node.childCompoundArray[0].rampAttribute
Sometimes the plugin works with one ramp attribute added, but crashes when I add another one next to the first.
(node.childCompoundArray[0].rampAttributeB)
Any ideas why this may happen?
Does Maya prohibit using ramp attributes as child attributes / in an array?
Or can this be the fault of having multiple ramp attributes next to each other?
I have not found anything in the official documentation on this matter.
I am using the Maya 2019 API.
Thanks in advance,
Peter
Could you please post a code sample that reproduces your issue?
Could you please post a code sample that reproduces your issue?
Sure!
// A static function that is called by the node's initializer.
// We pass the references to the static attribute MObjects.
// This function is used in several nodes to add the commonly used attributes.
// Unrelated code was omitted.
// All other attributes are working correctly (numeric, typed, compound, matrix etc.)
void SamplerUtils::createCommonAttributes(
MObject& sModifiers,
MObject& sModifierEnabled,
MObject& sModifierScaleRamp,
MObject& sModifierScaleFalloff,
MObject& sModifierDensityRamp,
MObject& sModifierDensityFalloff,
) {
MStatus status;
MFnNumericAttribute nAttr;
MFnCompoundAttribute cAttr;
sModifierEnabled = nAttr.create("modifierEnabled", "moden", MFnNumericData::kBoolean, 0, &status);
CHECK_MSTATUS(status);
nAttr.setDefault(true);
sModifierScaleFalloff = nAttr.create("modifierScaleFalloff", "modscf", MFnNumericData::kFloat, 10.0f, &status);
CHECK_MSTATUS(status);
nAttr.setMin(0.0f);
nAttr.setDefault(10.0f);
nAttr.setSoftMax(30.0f);
sModifierDensityFalloff = nAttr.create("modifierDensityFalloff", "moddef", MFnNumericData::kFloat, 10.0f, &status);
CHECK_MSTATUS(status);
nAttr.setMin(0.0f);
nAttr.setDefault(10.0f);
nAttr.setSoftMax(30.0f);
sModifierScaleRamp = MRampAttribute::createCurveRamp("modifierScaleRamp", "modscr", &status);
CHECK_MSTATUS(status);
sModifierDensityRamp = MRampAttribute::createCurveRamp("modifierDensityRamp", "modder", &status);
CHECK_MSTATUS(status);
sModifiers = cAttr.create("modifiers", "mod", &status);
CHECK_MSTATUS(status);
CHECK_MSTATUS(cAttr.addChild(sModifierEnabled));
// CRASH!
// CHECK_MSTATUS(cAttr.addChild(sModifierScaleRamp));
CHECK_MSTATUS(cAttr.addChild(sModifierScaleFalloff));
// CRASH!
// CHECK_MSTATUS(cAttr.addChild(sModifierDensityRamp));
CHECK_MSTATUS(cAttr.setArray(true));
CHECK_MSTATUS(MPxNode::addAttribute(sModifiers));
}
If I add the ramp attributes to the node itself, and not as a child in the compound it works - sometimes. Other times it still crashes Maya.
Péter
Sure!
// A static function that is called by the node's initializer.
// We pass the references to the static attribute MObjects.
// This function is used in several nodes to add the commonly used attributes.
// Unrelated code was omitted.
// All other attributes are working correctly (numeric, typed, compound, matrix etc.)
void SamplerUtils::createCommonAttributes(
MObject& sModifiers,
MObject& sModifierEnabled,
MObject& sModifierScaleRamp,
MObject& sModifierScaleFalloff,
MObject& sModifierDensityRamp,
MObject& sModifierDensityFalloff,
) {
MStatus status;
MFnNumericAttribute nAttr;
MFnCompoundAttribute cAttr;
sModifierEnabled = nAttr.create("modifierEnabled", "moden", MFnNumericData::kBoolean, 0, &status);
CHECK_MSTATUS(status);
nAttr.setDefault(true);
sModifierScaleFalloff = nAttr.create("modifierScaleFalloff", "modscf", MFnNumericData::kFloat, 10.0f, &status);
CHECK_MSTATUS(status);
nAttr.setMin(0.0f);
nAttr.setDefault(10.0f);
nAttr.setSoftMax(30.0f);
sModifierDensityFalloff = nAttr.create("modifierDensityFalloff", "moddef", MFnNumericData::kFloat, 10.0f, &status);
CHECK_MSTATUS(status);
nAttr.setMin(0.0f);
nAttr.setDefault(10.0f);
nAttr.setSoftMax(30.0f);
sModifierScaleRamp = MRampAttribute::createCurveRamp("modifierScaleRamp", "modscr", &status);
CHECK_MSTATUS(status);
sModifierDensityRamp = MRampAttribute::createCurveRamp("modifierDensityRamp", "modder", &status);
CHECK_MSTATUS(status);
sModifiers = cAttr.create("modifiers", "mod", &status);
CHECK_MSTATUS(status);
CHECK_MSTATUS(cAttr.addChild(sModifierEnabled));
// CRASH!
// CHECK_MSTATUS(cAttr.addChild(sModifierScaleRamp));
CHECK_MSTATUS(cAttr.addChild(sModifierScaleFalloff));
// CRASH!
// CHECK_MSTATUS(cAttr.addChild(sModifierDensityRamp));
CHECK_MSTATUS(cAttr.setArray(true));
CHECK_MSTATUS(MPxNode::addAttribute(sModifiers));
}
If I add the ramp attributes to the node itself, and not as a child in the compound it works - sometimes. Other times it still crashes Maya.
Péter
Can't find what you're looking for? Ask the community or share your knowledge.