PyMEL will convert the selection list for you to nodes (unlike MEL, where everything is a simple datatype.) At least this is true with ls
and related commands (selected
is just ls(sl=True)
.)
Everything in that list will be a subclass of PyNode
, so you can rely on them having a method nodeType
.
From there, it is easy to process each selection based on its type.
Components inherit from pymel.core.Component
, and there is one class for each component type; MeshVertex
for example.
You can use isinstance(obj, type_sequence)
to filter out components:
filter(lambda x: isinstance(x, (pm.MeshVertex, pm.MeshEdge, pm.MeshFace)), pm.selected())
You can find them under the general
section in the PyMEL docs.