View Full Version : Adding Multiple Atributes
vectormodeling 07-19-2004, 07:37 AM Hey, I am new to MEL and still fairly lost. I was wondering today how I could right a script that would add a series of custom attributes to a locator. I want to add a series of attributes that will be named in sequence (Adjust 1, Adjust 2, Adjust 3, etc) that will be linked through driven keys to the translate Y attributes of a series of objects named similarly to the custom attributes (object 1, object 2, object 3, etc). Is there a way to do this? I can only assume there is. I want to set this up for about a hundred objects, and I don't really want to do it manually, so I am putting it off. A MEL script would be great, or just some pointers.
MEL is such an extensive language that I am assuming there is a way to add a series of objects or attributes which are titled in a series.
Thanks.
|
|
mhovland
07-19-2004, 05:58 PM
{
string $selected[] = `ls -sl -fl`;
int $inc = 1;
for($i=0;$i<size($selected);$i++)
{
addAttr -ln ("Adjust" + $inc) -sn ("adj"+$inc) -at "float" -k 1 $selected[$i];
$inc++;
}
}
This will do what your looking for. Select all the objects you want to add the attributes to, and run the script.
If you want to add multiple attributes, just add them in the for loop after the addAttr line. Look up the addAttr command for what all the flags are doing. I just whipped up the framework, let me know if you want more than this, need more help, or want clarification on how this script is working.
vectormodeling
07-20-2004, 04:35 AM
Thanks for the reply. I hope you don't mind if I ask you some stupid questions, MEL, and coding in general, is still a total mystery to me.
When you say add "them" (other attributes) in the for loop, I am not really sure what you are talking about, as I don't know what a for loop is or where it might be in this little script.
Could you show me what the script would look like to add 5 attributes titled Attribute 1, Attribute 2, etc, to the current selection? I think this might give me a clearer understanding of what is changing and why. I think its going to take a long time to get used to MEL syntax.
Also, if you haven't run out of patience for the ignorant yet, how would you write a script that would link these 5 new attributes to the translate Y attributes of 5 corresponding cubes titled Cube_1, Cube_2, etc. It could be a proportional 1:1 connection (1:1, 5:5, etc). I have to admit I have no idea how to even start thinking about his.
One more thing: any recommendations for good MEL introductory reading material?
Thanks.
mhovland
07-21-2004, 10:33 PM
The answers to your quick questions get pretty involved :)
I will try to write up a detailed explaination tomorrow.
vectormodeling
07-23-2004, 05:49 AM
I don't mean to pester you with too many questions, thanks for helping out this much. I'm sure you've got more interesting things to do than explain MEL basics to beginners.
CGTalk Moderation
01-18-2006, 05:00 PM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.