SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / Walkerman's addAttributes Procedure
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 10-03-2006, 10:19 AM   #1
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default Walkerman's addAttributes Procedure

On this procedure, I will only list PART of it, it is very straigh-forward and relatively redundant, as far as the commands go.

If you want to view the WHOLE procedure, just open up the file you have downloaded . . .

If you want to step thru the action, you can call the addSkeleton procedure:

addSkeleton 1;


You may need to create the $n variable to make it work right when you step through manually

int $n = 1;

OK, so now we call the addAttributes procedure:


global proc addAttributes (int $n){

Again, we are passing the $n parameter so we know which skeleton we are adding the attributes to. . .

Now we build a string so we can plug it in to the addAttr command, so it will know where to add in the attribute.
If you were to do this command manually, you would select the joint you wanted to add the attribute to and under MODELING, you would go to modify>add attribute. After doing this on a joint, look in the script editor, and lo and behold, there is the code!

string $bb = "|bb" + $n;
addAttr -ln slope -k on -at double -min -50 -max 50 -dv 0 $bb;

"slope" is the name of the attribute we are adding.
-k on . . . allow keyframing
-at double . . . type of attribute, could be int, string, etc.
-min -50 . . . allow values only => -50
-max 50 . . . allow values only =< 50
-dv . . . default value of zero
-string $bb is obtained from previous line of code; it looks like
this: |bb1
bb1 is the parent of all the joints in the skeleton.



Same as explained above on the code that follows, just adding
more new attributes to joint bb1 . . .

addAttr -ln bodybounce -k on -dv .3 -at double $bb;
addAttr -ln fwdspeed -k on -dv 1 -at double $bb;
addAttr -ln clock -k on -at double $bb;
addAttr -ln initXposition -k on -at double $bb;




This attribute added below allows me to be able to control characters based on what type of character it is. . . I haven't coded the bird or spider yet, those will be future projects, unless someone here decides to beat me to it . . :attn:

//Character Type 1=Human 2=Bird 3=Spider 4=Quadraped
addAttr -ln characterType -r true -dv 1 $bb;




//Keep record of what character number for future reference.
This stores the character number right on the skeleton of the
character itself . . . so if I need to find out what the character
number is that is selected, I can just query this attribute.

addAttr -ln characterNumber -r true -dv $n $bb;



Here we build a second string, so we can add attributes to a new joint location . . .

string $mb = "|bb" + $n + "|mb" + $n;

-string $mb is obtained from previous line of code; it looks like
this: |bb1|mb1
bb1 is the parent of all the joints in the skeleton.
mb1 is the joint we are adding the attributes below to.

addAttr -ln basebacklean -k on -at double -dv 0 $mb;
addAttr -ln shoulderPivot -k on -at double $mb;



The rest of the code in the procedure is the same with of course some of the paths to joints much longer, so it would be dreadfully boring if I listed it all, and if you want to see it in action you can step through it in the script editor . . .



Then at the end I have:

This is just legacy stuff that I was using to position the perspective camera via MEL . . . commented out.
// Position Perspective view camera
//setAttr "persp.translateX" 30;
//setAttr "persp.translateY" 22;
//setAttr "persp.translateZ" 45;


// pause for one second . . . without this in here, I was having trouble with the attributributes all adding if I remember correctly,
If you ever run into a problem where you code seems perfect when you step through it, but you are not getting proper results when it actually runs, you might want to give this a shot.

pause -sec 1;

}

And that is all on the addAttributes procedure. . . .
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
skywola is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.