Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 22-03-2006 , 05:31 PM
Registered User
Join Date: Jan 2006
Location: Austria
Posts: 3

Joints and mel

hi,

does anyone know, how to get informations like:
parent, child, length, head or tail
from a joint with mel?

lg, leni

# 2 22-03-2006 , 06:02 PM
skywola's Avatar
Registered User
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
It is possible, I have been planning on a tutorial somewhat like what you are asking, the coding is more advanced, in that it takes several steps. I do have examples of it in my Walkerman program :

https://www.simplymaya.com/download_p...tid=6&typeid=4

or

Download > Mel Download > Animation Download


If you want to see working examples. All of it works thru following the joint heirarchy and querying attributes.

Listed below is a snippet of code I used in the module that turns the hand control on by editing expressions that control the joints in the hand. You can use the same process to get joint information.

Because of the limited width of this window, your better off downloading the Walkerman program and looking at the code in the handControlOn procedure in notepad . . .


// get main parent of all character parts
string $selectedObjects[] = `ls -sl -type joint`;
string $relBuffer[];
string $ultimate;
int $characterType;
int $characterNumber;

if (size($selectedObjects) == 0) {
string $window;
$window = `window -title "Walkerman" -iconName "Name" -widthHeight 200 55`;
columnLayout -adjustableColumn true;
text -label "\r\n\r\n Select a character to use its control window. \r\n\r\n" -fn "boldLabelFont" -align "center";
button -label "Close" -align "center" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
// Resize the main window
window -edit -widthHeight 300 114 $window;
}
else{
string $relBuffer[] = `listRelatives -f $selectedObjects[0]`;
$numTokens = `tokenize $relBuffer[0] "|" $relBuffer`;
if (size($selectedObjects) == 0)
print("You must select a character to turn hand control off.");
if (size($selectedObjects) > 1)
print("Select only one character part to get its control window.");
// Get characterNumber and characterType 1 = Human 2 = Bird 3 = Spider 4 = Quadraped (four legged) //
if (size($selectedObjects) == 1)
$ultimate = $relBuffer[0] + ".characterType";
$characterType = `getAttr $ultimate`;
$ultimate = $relBuffer[0] + ".characterNumber";
$characterNumber = `getAttr $ultimate`;

// HAND JOINTS
string $LBone = "LBone" + $characterNumber; string $FL2J1 = "FL2J1" + $characterNumber;
string $FL3J1 = "FL3J1" + $characterNumber; string $FL4J1 = "FL4J1" + $characterNumber;
string $FL5J2 = "FL5J2" + $characterNumber;
string $lw = "lw" + $characterNumber;

string $RBone = "RBone" + $characterNumber; string $FR2J1 = "FR2J1" + $characterNumber;
string $FR3J1 = "FR3J1" + $characterNumber; string $FR4J1 = "FR4J1" + $characterNumber;
string $FR5J2 = "FR5J2" + $characterNumber;
string $rw = "rw" + $characterNumber;
string $exp;



// get expressions from FL2J0
string $FL2J0 = "FL2J0" + $characterNumber;
// Get expressions connected to above joint
string $buffer[] = `listConnections -type expression $FL2J0`;
string $element;
string $compString;
string $expressionToEdit;

// edit expressions to de-activate hand control
for( $element in $buffer ){
$compString = `expression -q -s $element`; // query for present expression //
$expressionToEdit = $FL2J0 + ".rotateZ";
if(startsWith($compString, $expressionToEdit)){ // boolean - look for rotateZ //
$exp = $FL2J1 + ".rotateZ = " + $lw + ".leftGrab;"; // Left RZ Index Finger
expression -e -s $exp -o FL2J1 -ae 1 -uc all $element; // edit it
}
$expressionToEdit = $FL2J0 + ".rotateY";
if(startsWith($compString, $expressionToEdit)){ // boolean - look for rotateY //
$exp = $FL2J1 + ".rotateY = " + $lw + ".leftSpread * -.5;"; // Left RY Index Finger
expression -e -s $exp -o FL2J1 -ae 1 -uc all $element; // edit it
}
}


"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
# 3 22-03-2006 , 07:16 PM
Registered User
Join Date: Jan 2006
Location: Austria
Posts: 3

thanks!

thanks for your helpful information!

listConnection is one of the commands i searched for!
i will check out some of your code - it will help me a lot

lg, leni

# 4 23-03-2006 , 11:34 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
ok you don't need to search though all that code:

to get the

parent:
listRelatives -p <<object name>>

children:
listRelatives -c <<object name>>

to calculate the length of a joint just get the position of joint1 and then joint2 and do some vector maths to give you the length between them:

global proc float getJointLength(string $jnt1, string $jnt2)
{
//get jnt1 worldspace position
float $jnt1Pos[] = `xform -q -ws -t $jnt1`;

//get jnt2 worldspace position
float $jnt2Pos[] = `xform -q -ws -t $jnt2`;

//calculate the vector between them
float $xcomp = $jnt2Pos[0] -$jnt1Pos[0];
float $ycomp = $jnt2Pos[1] -$jnt1Pos[1];
float $zcomp = $jnt2Pos[2] -$jnt1Pos[2];

vector $tmp = << $xcomp, $ycomp, $zcomp>>;

//get the vector length
float $res = mag($tmp);
return $res;
}

getJointLength("joint1", "joint2");

and what do you mean by "head and tail"?

user added image
A


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 5 24-03-2006 , 07:38 AM
Registered User
Join Date: Jan 2006
Location: Austria
Posts: 3
hi,

thanks for your advices,
i am working on an export script for a bone-animated character (mesh + boneanimation)
the authors of the fileformat and the first script made their work with blender

i have used the fileformat to write an exporter with maxscript, and now i will do the same with mel

head = startposition of a bone
tail = endposition of a bone

so i will use position for head and position + length for tail

i am a little bit confused about the bone handling in maya, because i have worked with max before, where you have no joints, just bones - so every bone has a length
in maya seems to be joints (last joint of a bone-chain), which have no length

i have been searching for commands where i can get informations about joints and their hierachy, but i didn't search for the listX commands
...and coming from maxscripting, i was spoilt with a huge amount of commands for each kind of node, a lot of commands for mathematics and so on... user added image

lg, leni

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads