Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ramp attribute crash in compound attribute

2 REPLIES 2
Reply
Message 1 of 3
peter.kalmar
346 Views, 2 Replies

Ramp attribute crash in compound attribute

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

Labels (2)
2 REPLIES 2
Message 2 of 3
jmreinhart
in reply to: peter.kalmar

Could you please post a code sample that reproduces your issue?

Message 3 of 3
peter.kalmar
in reply to: jmreinhart

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.

Post to forums  

Autodesk Design & Make Report