Home Technical Talk

First Mel Script

Hey Polycounters

I recently was introduced to the world of Mel I was hoping someone could send me in the right direction to where I can find more tutorials. I've done a bunch of Google searches under the topic, but have come up short, most of the stuff online is Mel scripts tools that was created.

Any resources would be greatly appreciated.

Replies

  • haiddasalami
  • K17020
    Options
    Offline / Send Message
    Thanks very much I'll take a look, from what I hear to be any good at rigging or technical stuff in Maya you need to know Mel like the back of your hand
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    K17020 wrote: »
    Thanks very much I'll take a look, from what I hear to be any good at rigging or technical stuff in Maya you need to know Mel like the back of your hand

    I think the industry is moving more away from MEL and more to python/py-mel though knowing mel is always good.
  • gray
    Options
    Offline / Send Message
    I agree with haiddasalami.

    I think most TD work is done in python now. but maya uses mel for its interface and scripts and mel is part of the core application. from what i understand python and pymel are just a wrapper to the c++ api and the mel commands.

    but your going to find a huge amount of python tutorials books etc to learn.

    http://download.autodesk.com/global/docs/maya2012/en_us/PyMel/index.html

    anoter good thing to do is start reading scripts on creativecrash.com. most of the mel i know is from reading other peoples scripts.

    also get the maya docs and maya api docs for c++ and python so yo can look up up function etc.
  • jessicaB
    Options
    Offline / Send Message
    Yeah. The industry is moving fast so we have to be updated with the latest trends.
  • K17020
    Options
    Offline / Send Message
    Ya I know that there moving more to Python, but don't you have to load Mel script commands in to the Python engine when your in Maya? Also don't you need to understand Mel script syntax to get the most out of Python?
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    Open this folder:
    Program Files\Autodesk\Maya2012\scripts

    These directories are some of the best documentation you can have as a technical artist.
    Open up the script editor and 90% of what is echoed will come from Maya's scripts.
    Dissecting those scripts will give you more power under the hood even if yer final solution is python.
    Although Python is extremly important. As long as MAYA is built on top of mel in this way: ( MEL KNOWLEDGE WILL ALWAYS BE EXTREMELY IMPORTANT! )
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    The workflow to get the most out of the maya script directories is to...

    follow the action logic in the script editor echoes ( make sure you have "echo all" on when developing and off for performance )

    Then use your editor's "find in files" function to search in those directories the relevant procedures.
    I use to use Textpad for this. But for python and pymel a lot of people are using Eclipse. I find that Notepad++ is a hell of a lot faster than Textpad for searching:
    Program Files\Autodesk\Maya2012\scripts

    Almost instantaneous where Textpad would take about 25 seconds )

    Even when you find the correct procedure that executes the action that was echoed you will most likely have "to follow the logic" across multiple scripts. which is often EXTREMELY illuminating.
  • K17020
    Options
    Offline / Send Message
    Thanks for the heads up I greatly value your advice. I'm just trying to get my foot into coding, because I don't have any prior experience coding.
  • claydough
    Options
    Offline / Send Message
    claydough polycounter lvl 10
    As a for Instance...
    Cross posting from another forum where the following user was using the scripteditor to make macros without referring to the actual logic in the mel files:
    Help with command for paint selection tool.
    I have added 2 small scripts under the hot key editor to select and unselect with the paint selection tool.

    The problem is that the only commands I have came from what the script editor echoed, and things aren't working right.

    here's what i got so far:
    To paint select

    artSelectToolScript 4;
    artSelectPaintOperation artSelectCtx Select;
    artSelectValues artSelectContext;
    toolPropertyShow;


    and to paint unselect

    artSelectToolScript 4;
    artSelectPaintOperation artSelectCtx Unselect;
    artSelectValues artSelectContext;
    toolPropertyShow;

    The problem is that i have to have the artpaintselecttooloptions active for these to work. All i did was copy and paste the echoed mel commands from the artpaintselecttooloptions as I changed the option to select or unselect, but i can't figure out how to make things work without it being active.

    I just want a better way to tell maya that the paint selection tool should be unselecting or selecting.

    Thank you in advance.



    In which case...
    Here is the suggested fix that examines maya's intrenal script's involved to find a real solution:
    ( this was back in 2007 maya 8.5 but I think the same echoes are relevant )
    graduate from macros
    look up the echoed commands in the Maya command reference
    ( in yer case artSelectCtx ) it's as easy as going up to yer help menu

    Some commands echoed in the script editor are not part of the mel library base. Use a text editor's ( prefer textpad mahself ) "find in files" feature to search script directories ( particularly: Autodesk\Maya8.5\scripts )

    artSelectValues is a command found in Autodesk\Maya8.5\scripts\others
    artSelectValues.mel

    the problem ( the option window requirement ) you are having is from line
    80 of this script. It uses the option window ( toolPropertyWindow ) to query yer tools value preference. ( brush radius.. fer instance )

    Use optionVar with yer own ctx ( tool ) to git around using the artSelectValues.mel.

    in the following toggle example ( toggling command ... not the brush's toggle feature ):

    "bob" is the brush ctx tool
    "bobValues" are the "user preferences" that the optionVar command puts in your userPref.mel ( brush radius in the example )



    // replace yer hotkey wit me ( recalling this hotkey will toggle between...
    // ...select or unselect as long as the tool is being used.. )
    // begin
    {
    string $s[] ={ "toggle", "select", "unselect" };
    string $ss[0] = {"toggle"};
    string $d[];



    if (( `currentCtx`) == "bob" ) {
    $ss[1] = `artSelectCtx -q -selectop bob`;
    $d = stringArrayRemove( $ss, $s );
    deleteUI bob;
    }
    else {
    $d = {"select"};
    if ( `contextInfo -ex bob` )
    deleteUI bob;
    }



    if (! `optionVar -exists "bobValues"`)
    optionVar -fv "bobValues" 5.5;
    float $fv = `optionVar -q "bobValues"`;



    string $stringCmd = "{float $f = `artSelectCtx -q -r bob`; optionVar -fv bobValues $f;}";
    artSelectCtx -selectop $d -r $fv -bsc $stringCmd bob;
    setToolTo bob;
    }

    // hope that helps // Roger Klado was here


    http://www.3dbuzz.com/vbforum/showthread.php?154052-Help-with-command-for-paint-selection-tool.

    Hope that makes sense: ( Maya mel files are important sources of documentation )
  • gray
    Options
    Offline / Send Message
    K17020 wrote: »
    Thanks for the heads up I greatly value your advice. I'm just trying to get my foot into coding, because I don't have any prior experience coding.

    if your just starting out and you have no experience with another language it will be much easier to get a intro to programming book for python or c. that will teach you the BASICS. starting from scratch. you really do need to do that before you jump into mel or pymel. your not going to find a textbook style book going over basic programming concepts in mel and pymel. most texts for maya assume you have a good grasp or programming and assume you just need to learn a new syntax. then they give non-trivial examples. interfaces, 3d math, writing function etc. thats above what you should get into until you get the basics down imo.

    personally i like c. and for learning computer science and programming c is the way to go. stay away from java imo. there is a ton of good books on c. and stuff on the net.
  • K17020
    Options
    Offline / Send Message
    Ya I've been reading this book for a while ( [ame="http://www.amazon.com/MEL-Scripting-Character-Rig-Maya/dp/0321383532/ref=sr_1_3?ie=UTF8&qid=1328347790&sr=8-3"]Book[/ame] ), but its kind of dry and taking along time for me to go from reading it and using the concepts introduced in the book. What I'm really interested is in rigging and from my experience talking to other technical artist Programing is a must.
Sign In or Register to comment.