You dont need to have it as a selection, mel has a undocumented feature where any command accepts a list as a selection. So theres no need to expand it tough undo loop. instead you can just do:
ls -flatten pCube1.vtx[2:3]
This only works if the selection in the scene is possible tough. This is beneficial because updating undo is very slow for maya.