MEL scripts

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Search this Thread Display Modes
Old 07 July 2002   #16
one of the coolest places for tips and tricks for mel.
such a lot of useful explanations and tips.. this really helped me over some sleepless nights

http://www.ewertb.com/maya/
 
Old 07 July 2002   #17
a handy one, maybe someone can add a read out for the value data types this one doesn't print out

Code:
// list all readable attributes for the named node, if showExtendedInfo is set to true (anything except 0) the attribute's type and value (if possible) will be appended proc lsAttributesForNode(string $theNodeName, int $showExtendedInfo) { string $eachParameter; string $NodeName = $theNodeName; string $NodeAttributes[] = `listAttr -read $NodeName`; string $NodeAttributeType; for ($eachParameter in $NodeAttributes) { // query attribute's type $NodeAttributeType = `getAttr -type ($NodeName + "." + $eachParameter)`; print($NodeName + "." + $eachParameter + " "); if($showExtendedInfo) { switch ($NodeAttributeType) { case "byte": // pass on case "long": // pass on case "enum": // pass on case "enum": // pass on case "bool": // pass on case "float": // pass on case "string": print("[value = \"" + `getAttr ($NodeName + "." + $eachParameter)` + "\"]"); break; default: print("[value = i'm not yet smart enough to handle this one]"); break; } print(",[type = \"" + $NodeAttributeType + "\"]"); } print("\n"); // line feed } } // e.g. list all attributes, values and types from the default lambert1 shader node lsAttributesForNode("lambert1", 1);

Last edited by stunndman : 07 July 2002 at 07:38 PM.
 
Old 07 July 2002   #18
doesnt the DG node reference in the manuals derive this one obsolete?
 
Old 07 July 2002   #19
Quote:
Originally posted by alexx
doesnt the DG node reference in the manuals derive this one obsolete?


hmm, i have no clue what you are referring to

maybe it is - are you referring to a MEL command that already does this job?
 
Old 07 July 2002   #20
nope.

in the online docs to maya there is a thing calle "DG nodes reference" which holds all the information to a specific node and all its attributes.
e.g. you want to change the values in the render globals from a mel script: you wont get any helpfull feedback in the script editor. but al can be found there under "defaultRendergloabsl"..

have a look. there is even some info in, that is not in the regular manuals. very handy!

cheers

alexx
 
Old 07 July 2002   #21
ahh, got it - well, my manual doesn't show me the current (live) values of the node's attribute yet - would be nice though if someone could make a link to the html documentation showing the documentation of the currently selected node and it's active values

...
let me add - i'm using this one primarily for developing scripts - selecting nodes and looking up attributes in the attribute editor (opening the panes) can be tedious if i want to quickly verify conditions

Last edited by stunndman : 07 July 2002 at 07:53 PM.
 
Old 07 July 2002   #22
in the hypershade that is already there..
right click on the bottom of a node and the DG node help will pop up when you select the "help" line at the very bottom
 
Old 07 July 2002   #23
cool mel commands that no one knows

here are some really handy ones:

fromNativePath (windows to unix path string conversion)

toNativePath (windows to unix path string conversion)

filterExpand (expand selections like .cv[1:12][2:13] to single occurances)

encodeString (encode a string to escape characters like \ " )

baseName (get base name from a path string)
dirName (get the directory from a path string)

cmdFileOutput (writes output to a file)

flushUndo (clear the undo buffer: very handy in scripts that change a lot during execution to prevent overflow)

hope you found one, that you did not already know

cheers

alexx
 
Old 07 July 2002   #24
öäähmm yes some

mel is such a wonderfull thing in maya and it makes the real power. wrote a few nice scripts for good old stevie (you know who i mean ) but i definitly need to spend more on this
__________________
heimwerker never die
 
Old 07 July 2002   #25
skinning script

so here's one script i wrote the night long.

then i wanna weight a character and i use the paint weights tool it's difficult to select a joint and rotate him a bit to get another position and look how the skin mooves. i have to leave the paint tool select the joint and rotate it. (i know that there is a way with attrCollection, but attrCollection you first have to set all up)

this script is very easy to handle. there are two ways. you can load in only selected joints or the whole hirarchie of the selected joint. after that you can see your joints in the top window. if you select one you will see all the bound (to this joint) geometry.

the sliders on bottom (X-Axis;Y-Axis;Z-Axis) you can handle the rotations. there are also input fields for the min, max and current. if an attribute is locked, the fields and slider will also be locked.

now you can select a geometry from the list and hit paint. you'll be still able to rotate via the slider then the paint window is open.


i'm still not finished with commenting all out.

comments are very warm welcome

svenip

--==edit==--

updated with a more commented file
Attached Files
File Type: zip spskintools.zip (4.1 KB, 215 views)
__________________
heimwerker never die

Last edited by svenip : 07 July 2002 at 04:30 PM.
 
Old 07 July 2002   #26
Don't know if this allready exsist..
Just a little handy script if you are tired of deleting nodes from the Hypergraph.
Select a Node in the Channelbox, execute the script and the node is deleted:

Code:
string $Object[] = `ls -sl -tr -s`; select -d $Object; delete; select $Object;
__________________
http://mikkeljans.blogspot.com - My Scripting Blog!

Last edited by Mikkel Jans : 07 July 2002 at 05:56 PM.
 
Old 07 July 2002   #27
your script is good svenip but you can simply animate the bone where you working on and when you want to check the result you use your time slider and you can keep paint the weight
 
Old 07 July 2002   #28
yeah i know HADES it lacks a bit of usefullness because there are more ways (as i said via the attrCollection or your way) but it's just a start, i wll add more functions i'm always searching for then i do skinning
__________________
heimwerker never die
 
Old 07 July 2002   #29
cool svenip keep it up...........as l said your script is good but my way of skinnig is with lattice and flexor l got better result in no time with soft skin this take more time to get the same result if you got a tipm for smooth skin or a good tutorail tell me l will try it ...l m working in a 3d bisnees and l lways use this way....maybe if lget a better result in smooth that will be great..........keep it up
 
Old 07 July 2002   #30
Here's one of several name handling tools I've knocked out recently. Select any source object with left or right in its name and then a target object. The target will be renamed to that of the source with the opposite side.

For instance. If you select left_ulna and then select another joint and run the script the target joint will become right_ulna.

-----snip-----
proc int itemNthString (string $item, string $array[])
{
int $x;
int $theIndex = -1;

for ($x=0; $x<size($array); $x++)
{
if ($array[$x] == $item)
{
$theIndex = $x;
break;
}
}

return ($theIndex);
}

proc int stringWordPosition (string $item, string $matchString, string $wordChar){
string $tokenList[];
int $position;

tokenize $item $wordChar $tokenList;
$position = (`itemNthString $matchString $tokenList` + 1);

return $position;
}

proc int stringContains (string $theString, string $item){
string $matchString = ($item + "+");
int $returnInt = 0;

if (`match $matchString $theString` == $item){
$returnInt = 1;
}

return $returnInt;
}


global proc string stringReplaceNthWord (string $item, string $replace, int $position, string $wordChar){
string $tokenList[];
string $returnString;
int $x, $y;

tokenize $item $wordChar $tokenList;
$y = size($tokenList);

for ($x=0; $x<$y; $x++){
if ($x != ($position -1)){ //is this replace or copy?
if ($x != ($y-1)) //is this the last word?
{$returnString += ($tokenList[$x] + $wordChar);} //if not, then it's x + a wordChar
else
{$returnString += $tokenList[$x];} //else, it's just x
}
else{ //replace
if ($x != ($y-1))
{$returnString += ($replace + $wordChar);}
else
{$returnString += $replace;}
}

}

return $returnString;
}


global proc liftNflopName (){
string $sel[] = `ls-sl`;
string $side;
string $flopName;

int $position;

if (`stringContains $sel[0] "left"` == 1){
$side = "left";
$position = `stringWordPosition $sel[0] $side "_"`;
$flopName = `stringReplaceNthWord $sel[0] "right" $position "_"`;
}

if (`stringContains $sel[0] "right"` == 1){
$side = "right";
$position = `stringWordPosition $sel[0] $side "_"`;
$flopName = `stringReplaceNthWord $sel[0] "left" $position "_"`;
}

rename $sel[1] $flopName;
}

-jl
 
reply 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 03:14 AM.


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