forked from davegreenwood/zbw_python_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertexToUV.py
23 lines (19 loc) · 838 Bytes
/
vertexToUV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import maya.cmds as cmds
#-------could also select edit point????
#-------multiple selection and average uv position? Orrrr option to create multiple UV's, one on each vertex
#-------grab an edge and convert to 2 verts and get average. . .
#-------have option for distributed (select 2 verts and number of follicles, spread that num between the two uv positions)
#get vertex
vertex = cmds.ls(sl=True, fl=True)
#------check what type of selection you have and convert it to verts
#-------for loop here. . . .
#convert vertex to uvs
uvs = cmds.polyListComponentConversion(fv=True, tuv=True)
#flatten the uv to list and grab first (cuz verts can be multiple uv's)
uv = cmds.ls(uv, fl=True)[0]
#select our uv
cmds.select(uv, r=True)
#convert the uv index to u and v values
uvVal = cmds.polyEditUV(q=True)
cmds.select(vertex)
return(uvVal)