Strange issue with MPxNode::initialize()!Help!

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  12 December 2010
Strange issue with MPxNode::initialize()!Help!

Hi,
I get a really strange problem when deal with custom node's initialize() method!
Here's my code:
PHP 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 addAttributeaInColor1R );        _test(stat,"Add attribute color1R failed.");
    
stat addAttributeaInColor1G );        _test(stat,"Add attribute color1G failed.");
    
stat addAttributeaInColor1B );        _test(stat,"Add attribute color1B failed.");
    
stat addAttributeaInColor1 );        _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:
PHP Code:
 aInColor1R =nAttr.create("color1R","c1r",MFnNumericData::kFloat,0);
    
stat addAttributeaInColor1R );        _test(stat,"Add attribute color1R failed.");

    
aInColor1G =nAttr.create("color1G","c1g",MFnNumericData::kFloat,0);
    
stat addAttributeaInColor1G );        _test(stat,"Add attribute color1G failed.");

    
aInColor1B =nAttr.create("color1B","c1b",MFnNumericData::kFloat,0);
    
stat addAttributeaInColor1B );        _test(stat,"Add attribute color1B failed.");

    
aInColor1 nAttr.create("color1","c1",aInColor1R,aInColor1G,aInColor1B,&stat);
    
_test(stat,stat.errorString());
    
nAttr.setKeyable(true);
    
stat addAttributeaInColor1 );        _test(stat,"Add attribute color1 failed."); 

it worked, without any err. I get confused even more

So why did this happen? I use VS2005 and Maya2010, having no such problem before. Anyone had the same issue? Thanks!
__________________
You are the reason I love CGTalk, my kind-hearted friends!
 
  12 December 2010
when dealing with compound attributes, you don't need to add child attributes to node directly. only add the top level ones, in your case - only "aInColor1".
__________________
Victor
ngskintools.com - skinning plugin for Autodesk Maya
 
  12 December 2010
Originally Posted by uiron: when dealing with compound attributes, you don't need to add child attributes to node directly. only add the top level ones, in your case - only "aInColor1".


Sorry for my late reply, You are right Uiron, I remove the child adding and it initialized successfully! Thank you !
__________________
You are the reason I love CGTalk, my kind-hearted friends!
 
  12 December 2010
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:03 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.