Extract UV Coordinate Data of Mesh

Hi gang!

I have a mesh exported from 3ds max (obj) which contains mapping coordinates.

I am referencing this geo in GH to be deconstructed, ‘distorted’ and then rebuilt with the same vertex order (this step is OK).

However I am looking for a component/workflow that enables me to extract the UV data to then reapply to the newly constructed mesh. Does such method exist or is it a scripting solution?


You can do this with the simplest of python scripts:

"""Extract Mesh UV coordinates
        m: Mesh to extract UV coordinates from
        uvs: List of Texture Coordinates (UVs)"""

__author__ = "jesterKing"
__version__ = "2018.07.20"

import rhinoscriptsyntax as rs

uvs = m.TextureCoordinates

Set the m input type hint to Mesh, then connect a mesh parameter to it.

edit: attaching a GH definition with a script that does pretty much the same as the deconstruct mesh component, but in addition also gives you UVs

extract_mesh_uvs.gh (6.8 KB)


Thanks! looks great. Is it possible to then reapply these to a new mesh, assuming the vertex order is the same?

Order should be the same, yes.

Apologies, I am unsure of how to re-apply the UV data back to the reconstructed mesh. I am exporting from Rhino as an OBJ and have attempted to just manually paste the chunk of UV data into the .obj file in a text editor, however it appears that the syntax of the face data changes slightly after being deconstructed and then created again in grasshopper.

(left is the faces data exported from 3ds max, right is out of GH)

Therefore the when i re-import the geo into 3ds max the face and UV’s don’t appear to match up, Is there a way to construct the new mesh from the with the correct UV’s inside of grasshopper?

Hopefully this makes sense ! Thanks

The right side does not have uv coordinate indices, the right contains only vertex and vertex normal indices (https://en.wikipedia.org/wiki/Wavefront_.obj_file#Vertex_normal_indices_without_texture_coordinate_indices)

Regarding face vertex ordering I can’t say if one can expect them to be the same in a round-trip. I guess that strongly depends on the mesh representations possible in source and target.

That UV coordinate order is same as for vertex order inside Rhino still holds. Just make sure you also export texture coordinates.


Edit: you probably wanted to create OBJ with face in format: f v1/uv1 v2/uv2 v3/uv3

Hey, I read your post. I was not able to use it correctly or I cannot apply it on my mesh. Do you know what I am doing wrong?

mesh 01.gh (9.7 KB)

I think there is a misconception about what the Mesh Surface component does. It doesn’t create a mesh with UV (texture) coordinates. Rather it creates a mesh based on the given surface UV parametrization.

Hi, is there a explanation the processing power for DeMesh is quicker than GhPython?


Hi @jia.yeap,

Grasshopper component will always be faster than ghpython script, as it is compiled.

To lower the run time of the ghpython script, you can:
Not set the type hint for the input ‘m’ parameter.
Another one is not to let the ghpython component ‘do’ the iteration, but do it on your own.
deconstructMesh.gh (182.1 KB)

1 Like