Windows90
12-05-2010, 06:03 AM
Hi,
I get a really strange problem when deal with custom node's initialize() method!
Here's my code:
//#define _test(_stat,_str) if(!(_stat)){MGlobal::displayError(MString("")+_str);return _stat;}
// Create attrs
aInColor1R =nAttr.create("color1R","c1r",MFnNumericData::kFloat,0);
aInColor1G =nAttr.create("color1G","c1g",MFnNumericData::kFloat,0);
aInColor1B =nAttr.create("color1B","c1b",MFnNumericData::kFloat,0);
aInColor1 = nAttr.create("color1","c1",aInColor1R,aInColor1G,aInColor1B,&stat);
_test(stat,stat.errorString());
nAttr.setKeyable(true);
// Add attrs
stat = addAttribute( aInColor1R ); _test(stat,"Add attribute color1R failed.");
stat = addAttribute( aInColor1G ); _test(stat,"Add attribute color1G failed.");
stat = addAttribute( aInColor1B ); _test(stat,"Add attribute color1B failed.");
stat = addAttribute( aInColor1 ); _test(stat,"Add attribute color1 failed.");
As you see it's just a simple shading node's input color attribute.
When I compiled and try to load it into maya, Maya displays err say "Add attribute color1R failed.", and I checked the errString, it says "(kInvalidParameter): Object already exists"
I have no idea what maya is talking about. But when I try following code:
aInColor1R =nAttr.create("color1R","c1r",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1R ); _test(stat,"Add attribute color1R failed.");
aInColor1G =nAttr.create("color1G","c1g",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1G ); _test(stat,"Add attribute color1G failed.");
aInColor1B =nAttr.create("color1B","c1b",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1B ); _test(stat,"Add attribute color1B failed.");
aInColor1 = nAttr.create("color1","c1",aInColor1R,aInColor1G,aInColor1B,&stat);
_test(stat,stat.errorString());
nAttr.setKeyable(true);
stat = addAttribute( aInColor1 ); _test(stat,"Add attribute color1 failed.");
it worked, without any err. I get confused even more :surprised
So why did this happen? I use VS2005 and Maya2010, having no such problem before. Anyone had the same issue? Thanks!
I get a really strange problem when deal with custom node's initialize() method!
Here's my code:
//#define _test(_stat,_str) if(!(_stat)){MGlobal::displayError(MString("")+_str);return _stat;}
// Create attrs
aInColor1R =nAttr.create("color1R","c1r",MFnNumericData::kFloat,0);
aInColor1G =nAttr.create("color1G","c1g",MFnNumericData::kFloat,0);
aInColor1B =nAttr.create("color1B","c1b",MFnNumericData::kFloat,0);
aInColor1 = nAttr.create("color1","c1",aInColor1R,aInColor1G,aInColor1B,&stat);
_test(stat,stat.errorString());
nAttr.setKeyable(true);
// Add attrs
stat = addAttribute( aInColor1R ); _test(stat,"Add attribute color1R failed.");
stat = addAttribute( aInColor1G ); _test(stat,"Add attribute color1G failed.");
stat = addAttribute( aInColor1B ); _test(stat,"Add attribute color1B failed.");
stat = addAttribute( aInColor1 ); _test(stat,"Add attribute color1 failed.");
As you see it's just a simple shading node's input color attribute.
When I compiled and try to load it into maya, Maya displays err say "Add attribute color1R failed.", and I checked the errString, it says "(kInvalidParameter): Object already exists"
I have no idea what maya is talking about. But when I try following code:
aInColor1R =nAttr.create("color1R","c1r",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1R ); _test(stat,"Add attribute color1R failed.");
aInColor1G =nAttr.create("color1G","c1g",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1G ); _test(stat,"Add attribute color1G failed.");
aInColor1B =nAttr.create("color1B","c1b",MFnNumericData::kFloat,0);
stat = addAttribute( aInColor1B ); _test(stat,"Add attribute color1B failed.");
aInColor1 = nAttr.create("color1","c1",aInColor1R,aInColor1G,aInColor1B,&stat);
_test(stat,stat.errorString());
nAttr.setKeyable(true);
stat = addAttribute( aInColor1 ); _test(stat,"Add attribute color1 failed.");
it worked, without any err. I get confused even more :surprised
So why did this happen? I use VS2005 and Maya2010, having no such problem before. Anyone had the same issue? Thanks!
