When using maya's ls command when I'm selecting vertices and I want a list of the vertices I'm selecting, how can I use the type option so that I only get the vertices of a mesh?
Something like:
import pymel.core as pm
verts = pm.ls(sl=True, fl=True, type=[vertex? polymeshVtx?])
Im giving you the method with maya.cmds The second one could be a solution in pymel but there might be another easier method.
import maya.cmds as cmds
sel = cmds.ls(sl=True, o=True)[0]
sel_vtx = cmds.ls('{}.vtx[:]'.format(sel), fl=True)
import pymel.core as pm
obj_sh = pm.ls(sl=True, dag=True, type='mesh')[0]
vtx_nb = obj_sh._numVertices()
vtx_flatten = ['{}.vtx[{}]'.format(obj_sh,i) for i in vtx_nb]
--- EDIT ---
import pymel.core as pm
obj_sh = pm.ls(sl=True, dag=True, type='mesh')[0]
for v in obj_sh.vtx:
print(v)