View in #maya on Slack
@lazicdusan: can anyone maybe recommend a good learning source for PyMel? i ran into it in “Practical Maya Programming with Python” and in some code snippets here and there, though haven’t seen a lot of learning source for it…
@coal: I thought that first chapter in Rob’s book went over it fairly well. A lot of learning pymel is just being familiar with cmds and object oriented python. And theres plenty of resources out there for those.
@bob.w: Yeah, if you’re familiar with
cmds the initial work with pymel should be a simple transition. After that its digging just a bit deeper into what each
PyNode brings to the table
But Rob’s book is probably the best book-reference.If you’re running into specific issues, or if concepts aren’t clicking for you, don’t hesitate to ask.
@lazicdusan: tnx for the answer, i am familiar with ‘mel’ and ‘cmds’ and i’m using pymel it a bit, though i am always on the lookout for some quality new reading/watching material…in my studio though they heavily prefer ‘cmds’, they don’t really dig pymel so i can’t ask at work
@chrislesage: import pymel.core as perfectly_legitimate_module
@theodox: basically pymel is cmds tweaked to return things other than strings for most commands that usually find objects
@lazicdusan: true, it’s not enforced but advised in a friendly gun-to-the-head way
@theodox: the things have an OOP facade that lets you get around 'cmds.xform(something=x,y,z)
in favor ofsomething.translate.set(x,y,z)`
somewhat elderly intro here: http://thetechnicalartist.com/resources/intro-to-pymel/
The Technical Artist: Intro to Pymel
@chrislesage: One thing I found very helpful to learn PyMEL was realizing you could search the docs by using periods to dig into classes and subclasses.
eg. vector .vector and .vector. all return different result. “datatypes.vector.” shows you all the methods and attributes related to the vector datatype.
@lazicdusan: thank you sir, i just thought there’s way more to it than basic introductions…like for example i used it for quite a while until i found out that connecting attributes can be made with >> and disconnecting them with //…stuff like this is what i am always on the lookout for…
@chrislesage: If you write the book, I’ll buy a copy
@theodox: FWIW those behaviors can be emulated with a little pure python and cmds without the heavy pymel stuff as well
@bob.w: Yeah, there isn’t anything pymel is doing that can’t be achieved either through
cmds or the API. It just happens to provide a more pythonic interface over those two.
At the cost of speed
@theodox: @theodox shared a file: xform.py
@rgkovach: i prefer the thin wrappers over pymel.
@chrislesage: Aaron Maxwell covered magic methods (which is what that >> stuff is, I suppose) here, using a light Pandas clone as an example. https://powerfulpython.com/blog/rebellious-magic-methods-python-syntax/
@theodox: all of mGui does this under the hood too
@passerby: yeah pymel is like wrapping it in concrete makes it way to heavy
nice little wrapper though
maybe its because i am more used to other languages that require the use of
new to make a object instance, but i always forget you can use
map like that on constructors
@theodox: you could also do it as
return [Xform(n) for n in ([cmds.ls](http://cmds.ls)(**args, ***kwargs) or ]
or  for before 2016 when they finally stopped returning none for empty queries
oops, left out a right paren after the empty brackets