1 / 10

MEL

MEL. Scripting Overview. MEL commands. Maya help -> MEL command reference MEL command line Script editor Icon Window->General Editors->Script editor. Script editor. Type in commands Shelf button: highlight, cmd-click, drag Script file: File->source script. Attributes. sphere;

cahil
Télécharger la présentation

MEL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MEL Scripting Overview CIS682

  2. MEL commands • Maya help -> MEL command reference • MEL command line • Script editor • Icon • Window->General Editors->Script editor CIS682

  3. Script editor • Type in commands • Shelf button: highlight, cmd-click, drag • Script file: File->source script CIS682

  4. Attributes sphere; listAttr nurbsSphere1; getAttr nurbsSphere1.tx; setAttr nurbsSphere1.translateY 10; aliasAttr up nurbsSphere1.ty setAttr nurbsSphere1.up CIS682

  5. Simple Example For ($j=0; $j<10;$j++) { sphere; move –r 0 $j 0 } CIS682

  6. Example // arrayOfSpheres.mel // shows simple nested 'for' loops to create objects for ($i=0; $i<10; $i++) { for ($j=0; $j<10; $j++) { sphere; move -r $i $j 0; } }; CIS682

  7. // simpleKeyframes.mel // shows // setting object attributes (x and y translation in this case) // how to set the special *currentTime* variable // setting keyframes // the animation can then be played back sphere -name ball; currentTime 0; SetKey; currentTime 50; setAttr ball.translateX 10; SetKey; currentTime 100; setAttr ball.translateY 10; SetKey; currentTime 150; setAttr ball.translateX 0; SetKey; currentTime 200; setAttr ball.translateY 0; SetKey; Example CIS682

  8. Example // from www.robthebloke.org/mel/DATA_mesh.html polyCube -name myObj; $mesh = "myObj"; float $vert[]; int $vertexCount[] = `polyEvaluate -v myObj`; print ("number of vertices: " + $vertexCount[0] + "\n"); for($i=0;$i<$vertexCount[0];$i++) { // get world space vertex coords $vert = `xform -ws -q -t $mesh.vt[$i]`; // $mesh.vtx[$i] = << $vert[0], $vert[1], $vert[2] >>; print( $vert[0] + " " + $vert[1] + " " + $vert[2] + "\n" ); }; CIS682

  9. Animation expressions expression -s "nurbsSphere1.tx = sin(time)"; Manipulate time slider (or ‘hit play’) to move object Window->Animation Editors->Expression Editor Maya->Help Search on ‘MEL’ Differences between expression and MEL syntax CIS682

  10. Animation expressions // http://www.fundza.com/melquickref2/#expression1 // NOTE: `spherè returns 2 strings. that’s why $obj is an array // and why $obj[0] is used in the expression string $exp = ""; string $obj[]; int $i; for ($i=0;$i<3;$i++) { $obj = `sphere`; move (rand(-3,3)) (rand(-3,3)) (rand(-3,3)); $exp += "select -r " + $obj[0] + ";\n" + "move -moveY (rand(0,2));\n"; } $exp += "select -clear;\n"; expression -s $exp -ae 1; playbackOptions -min 1 -max 30; play; CIS682

More Related