Get/Set UV Coordinates of a Vertex

Get/Set UV Coordinates of a Vertex

Anonymous
Not applicable
15,496 Views
6 Replies
Message 1 of 7

Get/Set UV Coordinates of a Vertex

Anonymous
Not applicable

I'm using Maya 2018, and I'm new to MEL.

My question is simple; how can I Get/Set the UV coordinates of a vertex via script?

 

It seems Maya 2018 does not let you see the coordinates in the UV editor anymore.

0 Likes
Accepted solutions (1)
15,497 Views
6 Replies
Replies (6)
Message 2 of 7

rajasekaransurjen
Collaborator
Collaborator
0 Likes
Message 3 of 7

Anonymous
Not applicable

Well the technique I had to use, (which absolutely sucks and is utterly ridiculous), is this:

 

I used the pointPosition command to find the vertex's world position. Then I generated a closestPointOnMesh node and plugged in my mesh and the vertex's position. The closestPointOnMesh node then returned the UV parameters of the vertex.

 

As far as setting the vertex UV's I have no clue. And I really don't care enough to try. I can't believe I have to do this much work for something this simple.

0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

Here's how to return the UV's of a selected vertex:

 

import maya.cmds as cmds
import pymel.core as pm

cmds.ConvertSelectionToUVs()

UVValues = cmds.polyEditUV( query=True )

print str( UVValues )

 

Here's how to set the UV's of a selected vertex:

 

import maya.cmds as cmds
import pymel.core as pm

cmds.ConvertSelectionToUVs()

UVValues = cmds.polyEditUV( query=False, relative=False, uValue=1.0, vValue=0.0 )

Message 5 of 7

rickomax
Explorer
Explorer

Hi!

I've created a small and pretty basic MELScript that allows you setting the UV coordinates of the selected UV with values:

https://gist.github.com/rickomax/aba86182b11c4577757460265fea5b82 

Message 6 of 7

prakashmano1110
Community Visitor
Community Visitor

Thankyou for the solution.

The below code working fine 2020 version Maya, but not working in 2023 Maya. Is there any thing need to change in below?

 

import maya.cmds as cmds
import pymel.core as pm

cmds.ConvertSelectionToUVs()

UVValues = cmds.polyEditUV( query=True )

print str( UVValues )

0 Likes
Message 7 of 7

l.chabrier
Community Visitor
Community Visitor

import maya.cmds as cmds
import pymel.core as pm

cmds.ConvertSelectionToUVs()

UVValues = cmds.polyEditUV( query=True )

print str(str(UVValues))

Actually it just because of Python 3 

0 Likes