Started to learn MEL but i have noob questions still

Hi, I am a new user to Maya and I am learnning Mel now by myself. And I have a bunch of different questions on how to make some stuff happen. I did the begginers tutorials but I still have lots of “conceptual” and “practical” questions.

  1. Can I place a script inside a object to work on it or scripts only exists in the maya interface?
  2. Can I make a ENUM attribute trigger scripts? and how?
  3. Can expressions hold like mini scripts? like creating a window and its buttons execute commands if so how?
  4. if a script executes from an expression can I trigger it with an object attribute?
  5. The Command “scriptJob” looks pretty cool but I can’t find any info on how to implement it, are there any tutorials on it I could follow?
  6. If I create a rigg of a character in a file and reference it into another layout file, how do I make scripts that I did for it be referenced too?

I suspect you’re going to get a lot of answers on the theme of don’t learn mel, learn python. If you have the choice that really is what you should do: nowadays serious tool work is pretty much all done in Python, and if you don’t know much mel already you can save yourself a lot of frustration by jumping straight to Python.

That said:

  1. You can add script nodes into to a scene, which will fire when the scene is loaded/unloaded or on demand. Some people use that to distribute tools, since anybody opening the file will get the script. Other people hate that, since it’s running code before you can say “don’t!”
  2. To trigger any script on an attribute change, use a scriptJob with the attributeChanged flag. That will trigger a script when the user changes an attribute value: scriptJob -ac "pCube1.tx" "print \"hello world\""; will print out whenever the tx of the pCube1` is changed by the user (not by an animation, btw)
  3. Expressions can do almost anything, but you really want to avoid that. They will slow your scene down a lot if you start trying to do fancy stuff that evaluates the scene graph. Stick to math-heavy, script-light operations.
  4. Expressions only evaluate when the scene time changes
  5. ScriptJob – see above. You pass a condition to watch for and a script to run when that condition changes or when that event fires.
  6. Referencing will bring in scene content only; it will only include scripts if they are part of the referenced scene, such as expressions or script nodes. Scripts in your user environment will always be available (they’ll be in your maya script directory
3 Likes

So thank you for the replay Theodox. I must say it was very enlightening for me!

I think I will be able to learn mel better as I am getting a better understanding of each section impact on a scene.

As for python I have been wanting to learn it for some time now but I wanted to learn maya first so I kinda fell on mel as it seemed pretty straightforward, but I will be surely more motivated to learn python with Maya too. I have been looking at their differences now and I think I can see why python has a bigger impact, thank you for bringing it to my attention.

Gonna do some mel experimentations now :slight_smile: