CGTalk > Software Specific Forums > Autodesk Maya > Maya Programming
To minimize the ads you see on this page create a CGTalk account and log in HERE
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 12-05-2010, 07:03 AM   #1
Windows90
Frequenter
 
Windows90's Avatar
portfolio
Cuckon Sue
Newb
Jinan, China
 
Join Date: Aug 2007
Posts: 108
Send a message via MSN to Windows90
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!
 
Old 12-06-2010, 07:52 AM   #2
uiron
neglostyti
 
uiron's Avatar
portfolio
Viktoras Makauskas
Lithuania
 
Join Date: Jun 2005
Posts: 592
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
 
Old 12-08-2010, 02:53 PM   #3
Windows90
Frequenter
 
Windows90's Avatar
portfolio
Cuckon Sue
Newb
Jinan, China
 
Join Date: Aug 2007
Posts: 108
Send a message via MSN to Windows90
Quote:
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!
 
Old 12-08-2010, 02:53 PM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:44 PM.


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