Hmm - so it appears that there's an undocumented method of MFnMesh
that will retrieve uvShells:

getUvShellsIds

Unfortuantely, since it's undocumented, there's no easy to use pymel
version - here's an example of how you might use it with straight api
methods:

http://pastebin.com/f341db1c0

import maya.OpenMaya as om

def getUvShells_api(object):
    mobj = om.MObject()
    selList = om.MSelectionList()
    selList.add(object)
    selList.getDependNode(0, mobj)

    mesh = om.MFnMesh(mobj)

    mscript = om.MScriptUtil()
    numUvShells_ptr = mscript.asUintPtr()
    uvShellIds = om.MIntArray()

    mesh.getUvShellsIds(uvShellIds, numUvShells_ptr)

    nbUvShells = om.MScriptUtil(numUvShells_ptr).asUint()

    shells = []
    for shell in xrange(nbUvShells):
        shells.append([])

    for i in xrange(uvShellIds.length()):
        shells[uvShellIds[i]].append(i)

    return shells


...this is derived from:
      /docs/Maya2009/en_US/API/flip_u_v_cmd_8cpp-example.html

However, this only gives you what shell a given uvIndex is on - ie,
the indices for the list(s) of uvs returned by MFnMesh.getUVs().

In order to find what faces / vertices these uvs are associated with,
you need to parse through each polygon, and then through each
polygon's vertices, to find the associated uv.  You can find an
example of doing this in (second code section):

     
/docs/Maya2009/en_US/index.html?url=Polygon_API_splitUVCmd_example.htm,topicNumber=d0e650174

However, as you can see, it's getting to the point where it's probably
more trouble than it's worth, especially if the only problem is you
want to avoid messing with the selection.  My advice is to just bite
the bullet and do ye' olde

savedSel = ls(sl=1)
cmdThatMessesWithSelection()
select(savedSel)

Not very aesthetic, I know... but once I realized that maya's built in
mel scripts do this anyway, I started wondering what the point of my
keeping the selection pure and untouched was...

- Paul


On Thu, Mar 19, 2009 at 6:23 AM, Sylvain Berger
<[email protected]> wrote:
> if you can figure it out, do you think that adding a method getPolyshells()
> to the shape object would be a good idea?
> Calling this method would return a 2d list of faces shells.
> So far I didn't found a command that could return the shells without having
> to select them in the UI. Maybe it is possible with the API but I am so bad
> with the API that I can't figure this one out
> thanks
>
> On Thu, Mar 19, 2009 at 2:06 AM, Chad Dombrova <[email protected]> wrote:
>>
>> that's a tricky one. i'll have to take some time to look it over.
>>
>> -chad
>>
>>
>> > So I finally took the time to look at pymel ... WOW! I mean WOW! I had
>> > no Idea it was this powerful! I knew it would be nice, but not like
>> > that. I am extremely impressed and pleased. Great work guys...really
>> > great!
>> >
>> > Now for my question.
>> > I am looking at a way of getting all the poly shells from a mesh.  I
>> > have this function I did in the standard python for maya that does the
>> > following.
>> > 1) list all the faces of the mesh,
>> > 2) select the first face, grow the selection to shell (using the
>> > polySelect(extendToShell=True) function),
>> > 3) list the selected faces of that shell
>> > 4) store those faces in a list,
>> > 5) remove those faces from the list created at #1
>> > 6) repeat step 2 to 5 until the first list is empty.
>> >
>> > It works but the function selects the faces in the UI, and I quite
>> > dislike it.
>> >
>> > Any idea how I could improve that using pymel?
>> >
>> > Thanks
>> >
>> > >
>>
>>
>>
>
>
>
> --
> They say, "Evil prevails when good men fail to act." What they ought to say
> is, "Evil prevails."
> Nicolas Cage as Yuri Orlov in Lord of War.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to