In this example, we will be looking at how to get information about UVs on a polygonal object. We will look at examining how many UV sets the object contains, getting the UVs for a given part of the object, and grabbing the position of a given UV point.
We will also look at how to convert one kind of selection to another and use that to determine if a given edge can be split or not.
Make sure that you have a scene that contains at least one polygonal object that has UVs—either an object that you have unwrapped or any of the built-in primitive shapes, which have UVs by default.
Create a new file, name it uvInfo.py
(or similar), and add the following code:
import maya.cmds as cmds def uvInfo(): sel = cmds.ls(selection=True) obj = sel[0] uvs = cmds.polyEvaluate(obj, uvComponent=True) uvPos = cmds.polyEditUV(obj + '.map[0]', query=True) isFirstEdgeSplit = isSplitEdge(obj, 0) print('Num UVs: ' + str(uvs)) print(...