Hi there,
I now got the basics of MEL. Now I’m thinking of getting my next tutorial/book. There are two things I’m not sure about. Does PyMel replace Python? So would be learning pyMel be my next step, or do I rather learn Python to have a good knowledge of MEL and Python itself?
I don’t really get what pyMel is.
Other question is if there are tutorials/books for either PyMel or Python especially for Maya users (Rigging).
Search out python for artists that should wet ur appetite.
Really some core python understanding before pymel.
For data structures using them effectively and general options for ways of doing things.
Maya python will be a more straight forward progression as you can still work in much the same way as Mel without having to understand the oop side of things until your ready to take that step. There will still be some stuff that is challenging enough to get your head around working that way.
I’d recommend finding a MEL script that you want to turn into python. Do that, line by line. Pick one with a UI as well.
This will likely result in workable, but not very pretty/efficient code.
So the next step could be optimizing small sections at a time. Check out python list slicing/comprehension, string manipulation, etc… Work small scale. Get familiar with the python data types.
Now your script is probably looking a lot better, but still resembles a MEL script in overall structure.
On your third pass, how about redesigning the code into a more pythonic structure? Design your own classes, separate out the UI code from the actual working code, so you could call your method via the UI or straight from a python command in maya.
If you are creating general methods which are going to be useful in more scripts than just this one, create a separate module for those, and import it.
Fourth pass, drop in some useful additional features that utilize python’s modules, such as logging, exceptions, profiling…
Note this is advice for learning the process, I wouldn’t usually go about converting a MEL script this way
[QUOTE=dbsmith;10801]I’d recommend finding a MEL script that you want to turn into python. Do that, line by line. Pick one with a UI as well.
This will likely result in workable, but not very pretty/efficient code. … Note this is advice for learning the process, I wouldn’t usually go about converting a MEL script this way :)[/QUOTE]
Also for learning you can use PyMel’s string converter and script converter scripts to create Python versions of MEL scripts. Though it doesn’t always seem to do it the best way, it can shed some insight into syntax at least.