Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Batman by Jason Edwards
You are here > Home > SimplyMaya Community Forums

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 10-03-2006, 10:19 AM   #1
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

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.