Any workaround for rs.GetMeshVertices() and rs.MeshTextureCoordinates()?

I am currently working on some python scripts and need these two funciton. They are both not implemented (yet) in python. Is there any workaround for them?

I appreciate any help as I am fairly new to python scripting in Rhino.


Hi bernd,

You might be using an older Service Release. rs.GetMeshVertices has been implemented to python. Check the function code in here.

As for the MeshTextureCoordinates, you can try something like this:

import rhinoscriptsyntax as rs

def MeshTextureCoordinates(object_id):
    # Returns normalized 2-D texture coordinates of a mesh object
    meshObj = rs.coercemesh(object_id)
    mCoordL = []
    for i in range(meshObj.TextureCoordinates.Count):
    return mCoordL

meshId = rs.GetObject("pick up your mesh")
coord = MeshTextureCoordinates(meshId)

Thanks for your quick reply. Indeed it is implemented, but seems to work incorrectly.

import rhinoscriptsyntax as rs

msh = rs.GetObject('Select mesh', filter=32)

mesh = rs.coercemesh(msh)
dots = []

for i, v in enumerate(mesh.Vertices):
    dots.append(rs.AddTextDot(i, v))

rs.AddObjectsToGroup(dots, rs.AddGroup())

vert = rs.GetMeshVertices(msh, 'select vert',1,0)
print vert

If you create a simple mesh and run the code above, it’ll number the verts and then asks you to select verts. After that their indices are printed. Those indices are different from the ones that are in the viewport. Any idea why?

Sorry, no idea why ComponentIndex.Index and Vertices properties return different mesh vertex index values. Maybe some of the McNeel guys will tell you why.

I edited the upper reply for MeshTextureCoordinates function.

hi djordje,

thanks lot for the MeshTextureCoordinates function, it works fine :slight_smile:

EDIT: So I stumbled upon this:
It seems that one of the functions returns topology vertices, but not the other.