adding additive dynamic atribute names

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
Old 03 March 2009   #1
adding additive dynamic atribute names

I need my script to create a control curve and add an atribute named "nelson"... (it first should check if the name exists... ok... till here). But if I run the script again it should find the "nelson" attribute and create a "nelson1", "nelson2", "nelson3"... and so on. And Iīm failing on figuring this out.

If it was only a Maya object... maya would automatically rename it for me. What doesīt happen with custom attribute names.

Can anybody help??
__________________
Nelson Teixeira
e-mail & MSN: nelson3d@gmail.com

Site: http://www.nelson3d.com

Anim Short



 
Old 03 March 2009   #2
re:

how about this:


  string $node = "newCurve";
  int $added;
  int $append;
  while(!$added)
  {
if( `attributeExists ("nelson"+$append) $node` ) {
$append++;
} else {
addAttr -at "float" -ln ("nelson"+$append) $node; break;
}
}


this above code is freehand, so there may be some syntax errors.
 
Old 03 March 2009   #3
Thanx for the quick code... I think I can adapt the idea to solve my problem... just have to figure out a way about checking the existing attributes, because if I create a new control after running the script several times and run the script on this new control... the naming will start on "nelson7" (for example).

I added a line to show the attribute on the channel box either. Hereīs how itīs looking so far. But I didnīt have free time to get the thing done. Just wanted to thank you for the help.

 string $nodes[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1` ;

 int $added;
 int $append;
 while(!$added)
 {if( `attributeExists ("nelson"+$append) $nodes[0]` )
 {$append++;
 }
 else
 {
 addAttr -at "float" -ln  ("nelson"+$append) $nodes[0];
 setAttr -e -keyable true ($nodes[0] + "." + ("nelson"+$append));

 break;
 }
 }

__________________
Nelson Teixeira
e-mail & MSN: nelson3d@gmail.com

Site: http://www.nelson3d.com

Anim Short



 
Old 03 March 2009   #4
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 08:16 AM.


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