Creating UV shells with Open Maya when importing custom mesh data

I’m using Maya API 2.0 to import a mesh from a custom format.
I have the verts and polys building correctly,
and all the UV coordinates are correct - but only for the for the “first” UV shell.

what I want:
image

what I get:
image

For the remaining shells, I have discontinuous UV data
describing verts shared across polygons with different UVs

{
	83: [
		(213, [0.2102842628955841, 0.9795976281166077]),
		(214, [0.2102842628955841, 0.9795976281166077]), 
		(327, [0.6289558412102842, 0.1166077979597628]),
		(329, [0.6289558412102842, 0.1166077979597628]),
		],
...
}

so vertex[83] has identical UVs inside polys[213,214]
and a second set of UVs inside polys[327,329], thus a different island

I’m not sure how to build the remaining UV shells with MfnMesh

Looks like you are doing the uv operation per vertex but it should be happening per uv which as you stated are not always 1 to 1. Apologies if I am stating something obvious.

If I understand correctly, OpenMaya and MFnMesh can account for this by building an intermediate mapping of face-vertices to UVs - in your case you might need to do a pass with numpy to collect all the coordinates that are equal (as the discrete vertices to use in the UV mesh, and then build the uv mesh out of those. Then you can specify the mapping of vertices from the UV mesh, to the actual vertices in the physical mesh

Yes that is the issue. I have to chunks of UV data: a continuous chunk and a discontinuous chunk. The continuous chunk is 1 per vertex, so the array is the same length as the vertex list. I’m passing these continuous UVs to MfNMesh.create() ; this leaves out the duplicated verts with multiple UVs

The doc s around the UV args are a bit unclear; I did not realize the data needs to be in face-vertex order

It looks like I need to combine the continuous and discontinuous UV data to produce UV data that maps to the face-vertex list

In maya , should process UV with ‘FaceVertex’ method.

I’m also stuck on this, does anyone has a practical solution?