The user guides documentation use a CAttrData and ExtensionAttrHelper to add new attribute in a maya node . like this:
https://support.solidangle.com/display/A5AFMUG/Adding+specific+Arnold+attributes+to+a+node
So , I wrote a new node to do the test .
static void NodeInitialiser(CAbTranslator context)
{
CExtensionAttrHelper helper(context.maya,"procedural");
CAttrData data;
data.stringDefault = MString("");
data.name = "wahaha";
data.shortName = "wahaha";
helper.MakeInputEnum(data);
}
When I use this method, I encountered an error. :
API error detected in plugins\mtoa\attributes\AttrHelper.cpp at line 1301 : (kInvalidParameter): Object is incompatible with this method
Also, no attributes are added to the my node.
Please tell me why and how to fix it... thank you so much ~~
Hi,
here's an example of how enum attributes have to be created :
CAttrData data;
MStringArray strArr;
strArr.append("Fixed");
strArr.append("Grid");
data.enums = strArr;
data.defaultValue.INT() = 0;
data.name = "aiTextureCoordinateMethod";
data.shortName = "ai_texture_coordinate_method";
helper.MakeInputEnum(data);
Thank you so much for your help ~~
But i still have problem when i do this :
void Wahaha_Translator::NodeInitialiser(CAbTranslator context)
{
CExtensionAttrHelper helper(context.maya,"procedural"); //CShapeTranslator::MakeCommonAttributes(helper); //CShapeTranslator::MakeMayaVisibilityFlags(helper);
CAttrData data;
MStringArray strArr;
strArr.append("Fixed");
strArr.append("Grid");
data.enums = strArr;
data.defaultValue.INT() = 0;
data.name = "aiTextureCoordinateMethod";
data.shortName = "ai_texture_coordinate_method";
helper.MakeInputEnum(data);
}
The same error message , no attributes are added to the my node again .
If i cancel the comment in the code ,
CShapeTranslator::MakeCommonAttributes(helper); or
CShapeTranslator::MakeMayaVisibilityFlags(helper);
Maya will crash ...
I am trying to write a maya shape node and translate it with mtoa .Working with MAYA2017-UPDATE3 and MTOA 2.0.2 and Arnold 5.0.1.2 .
https://support.solidangle.com/display/A5AFMUG/Adding+specific+Arnold+attributes+to+a+node
I have done the contents of the document once , but i can get the expected results . The "aiSpecularWeight" attribute dose not appear in the phong node .
Dose anyone know why ? Thank you so much ~~
Hi , sorry for reply you so late. I'm using win10 , vs2010 . I found another way to fix this problem during this time . I created a similar class using MAYA API to fix it .