How to Get UV_Editor Unwraped Mesh Without using UV_Editor command in C#?

Hi all,
I’ve tried to move the textureMapping with UvwTrabsform but it doesn’t work (or not as expected). Fortunately, using UV_Editor command and moving the mesh created by this command gives me right result.

But What I have to do is to edit my own uv in RhinoCommon in C#.
So I want to know how to get or modify the object without using UV_Editor command, thanks!

@maxsoder - is this something you can help with?

1 Like

I think Jussi might know better. @Jussi_Aaltonen

1 Like

Hi @Justin12, the easiest way to get the UV meshes in the document is to script the _ExtractUVMesh command. You can to the same by accessing the mesh (or render meshes in case of breps) and using the mesh texture coordinates as vertex positions.

In case of mesh UV coordinates you can transform them directly using SetTextureCoordinate method.

_
c.

Hi @Justin12
You can also directly access the mapping primitive and use its uv’s to create those meshes. Something like this:

  1. Get TextureMapping for the object using RhinoObject.GetTextureMapping
  2. Use TextureMapping.TryGetMappingMesh to get a 3d mapping mesh
  3. Create a 2d uv mesh by using the texture coordinates from the 3d mapping mesh. Depending on your application you may want to apply mapping uvw transform to the uv mesh.
  4. If you want bunch of separate meshes instead of a single mesh then explode the uv mesh

And if you want to modify the custom mapping then take a look at this simple sample code rhino-developer-samples/SampleCsCustomMeshMappingCommand.cs at 7 · mcneel/rhino-developer-samples · GitHub

Mapping UVW transforms on polysurfaces with packed textures (textures are packed by default) are not working correctly. I’ve filed the bug for Rhino WIP:
RH-69752 Mapping UVW transform wrong on poly surfaces with packed textures

1 Like

Hi @Jussi_Aaltonen ,
Thanks for your replying, I’ll do some test and reply you after that.

Thank you!