There is currently no MEL command to find the number of shells in a given UV set (I'm pretty sure of it).
Either way, new to Maya 2011 is an API method that identifies which UVs belong to which shell, and the total number of shells for a given UV set, and this post provides a short example of how to roll it into a python script.
Download a short Python script that will return the number of shells in a given UV set, for selected objects.
To use it, declare the procedure findUvShells() (eg: open the script in the Script Editor and execute it once), select a polygon object, then run :
findUvShells ('yourUvSet')
The return value is an array of strings that lists the selected mesh node name followed by the number of shells in 'yourUvSet'....
For example, if I have a pCube with a UV set called "owen", and for this UV set I've unitized the UVs per face (so 6 shells), I would select pCube and type:
findUvShells('owen')
[u'|pCube1|pCubeShape1', '6']
# note that '6' is a string var - see line 37 of the script #
To access this data, I've used the method OpenMaya.MFnMesh.getUvShellsIds(MIntArray uvShellIds, int & nbUvShells, string uvSet)
The documentation explains that this method "Constructs an array of unique integer for each UV shell. This method lets the user identify each connected piece of UV.
The uvShellIds array that is returned will contain a UV shell number for each UV in the given UV set. This number uniquely identifies a connected piece in the UV set. Numbers are positive, starting at 0.
For example, the array { 0, 0, 0, 1, 1, 1, 1, 0} would represent an object where UVs 0, 1, 2 and 7 are connected together (UV shell number 0), and UVs 3 to 6 belong to shell number 1".
- Parameters:
-
[out] uvShellIds The container for the uv shell Ids [out] nbUvShells The number of UV shells in this UV set. [in] uvSet UV set to work with
Owen
Cheers, i spend a few days banging my head trying to do this exact thing with python/API a few weeks ago. I'd forgotten to initialize the MScriptUtil with a uInt...
Used this method to rewrite the move_and_sew tool - we found it didn't always move the "smallest area" UV shell towards the larger one.
Posted by: dbsmith | 02/03/2011 at 04:10 AM