<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ramp attribute crash in compound attribute in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10585904#M3656</link>
    <description>&lt;P&gt;Could you please post a code sample that reproduces your issue?&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 22:45:23 GMT</pubDate>
    <dc:creator>jmreinhart</dc:creator>
    <dc:date>2021-08-30T22:45:23Z</dc:date>
    <item>
      <title>Ramp attribute crash in compound attribute</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10584720#M3655</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;I am making a C++ plugin and I have a weird crash when using MRampAttributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an MPxNode, which has a child array of compound attributes.&lt;BR /&gt;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.&lt;/P&gt;&lt;P&gt;So the desired structure would be:&lt;BR /&gt;&lt;STRONG&gt;node.childCompoundArray[0].rampAttribute&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes the plugin works with one ramp attribute added, but crashes when I add another one next to the first.&lt;/P&gt;&lt;P&gt;(&lt;STRONG&gt;node.childCompoundArray[0].rampAttributeB&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why this may happen?&lt;/P&gt;&lt;P&gt;Does Maya prohibit using ramp attributes as child attributes / in an array?&lt;/P&gt;&lt;P&gt;Or can this be the fault of having multiple ramp attributes next to each other?&lt;/P&gt;&lt;P&gt;I have not found anything in the official documentation on this matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the Maya 2019 API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:47:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10584720#M3655</guid>
      <dc:creator>peter.kalmar</dc:creator>
      <dc:date>2021-08-30T13:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Ramp attribute crash in compound attribute</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10585904#M3656</link>
      <description>&lt;P&gt;Could you please post a code sample that reproduces your issue?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 22:45:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10585904#M3656</guid>
      <dc:creator>jmreinhart</dc:creator>
      <dc:date>2021-08-30T22:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ramp attribute crash in compound attribute</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10586896#M3657</link>
      <description>&lt;P&gt;Sure!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;// 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&amp;amp; sModifiers,
	MObject&amp;amp; sModifierEnabled,
	MObject&amp;amp; sModifierScaleRamp,
	MObject&amp;amp; sModifierScaleFalloff,
	MObject&amp;amp; sModifierDensityRamp,
	MObject&amp;amp; sModifierDensityFalloff,
) {
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnCompoundAttribute cAttr;

	sModifierEnabled = nAttr.create("modifierEnabled", "moden", MFnNumericData::kBoolean, 0, &amp;amp;status);
	CHECK_MSTATUS(status);
	nAttr.setDefault(true);

	sModifierScaleFalloff = nAttr.create("modifierScaleFalloff", "modscf", MFnNumericData::kFloat, 10.0f, &amp;amp;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, &amp;amp;status);
	CHECK_MSTATUS(status);
	nAttr.setMin(0.0f);
	nAttr.setDefault(10.0f);
	nAttr.setSoftMax(30.0f);

	sModifierScaleRamp = MRampAttribute::createCurveRamp("modifierScaleRamp", "modscr", &amp;amp;status);
	CHECK_MSTATUS(status);

	sModifierDensityRamp = MRampAttribute::createCurveRamp("modifierDensityRamp", "modder", &amp;amp;status);
	CHECK_MSTATUS(status);

	sModifiers = cAttr.create("modifiers", "mod", &amp;amp;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));
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Péter&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 09:11:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/ramp-attribute-crash-in-compound-attribute/m-p/10586896#M3657</guid>
      <dc:creator>peter.kalmar</dc:creator>
      <dc:date>2021-08-31T09:11:03Z</dc:date>
    </item>
  </channel>
</rss>

