Getting vert index from a PyMel MeshVertex

Hi all,

Right now in a script I have a list of MeshVertex, but I need a list of vert indices. I can convert them into strings and strip out the index part, but that seems expensive for many thousands of verts. Isn’t there a build in property or function I can use to get the index of the vert, from a MeshVertex?


If you are doing a lot of work on thousands of verts, and this is more than a one-time or occasional thing, you’ll likely want to invest the time in using OpenMaya API.

Depending on what you’re doing and how many components, a very realistic comparison is that API operations can take 0.1 seconds instead of 45 seconds in pymel, cmds, or mel.

Very true, speed is already an issue in my code, but I’m just trying to get something done ASAP for now. I’ll pivot into querying the selection of verts via the API, should help a lot thanks!

While I agree with @clesage that the API is going to be much faster, to answer the original question pymel.core.general.MeshVertex has an index method that should return the index of the vertex.

1 Like

Wow, you’re right… I swear I tried .index() but I must have made a typo…

Well I refactored the code into API calls with some excellent help from this blog and now things are indeed several times faster.

Thanks all!

1 Like