When you say "the first mesh", I think you mean the first shell? Your 
script only runs on one mesh, but appears to be trying to deal with the 
mesh one shell at a time.

Have you confirmed you script is correctly finding the shells? I can't 
tell, by reading it. If the polygons are correct for the first shell, but 
not correct after that, then I expect the problem is in the script that 
separates the face indices into shells.

Here is a different version. I think it should do the same thing yours is 
intended to do. It's written using API 2.0 so might require a few changes.

def mesh_to_shells(dp_node):
    """ Returns a list of lists of face IDs. """
    mfn_mesh = OpenMaya.MFnMesh(dp_node)
    mit_poly = om.MItMeshPolygon(dp_node)
    shells = []
    already_sorted = set()
    for id in range(mfn_mesh.numPolygons()):
        if id in already_sorted:
            continue
        this_shell = [id]
        # Starting with a single face, we keep adding connected face IDs to 
        # the end of the list, until we can't find any new ones.
        id_within_shell = 0
        while id_within_shell < len(this_shell):
            mit_poly.setIndex(this_shell[id_within_shell])
            id_within_shell += 1
            connected_IDs = set(mit_poly.getConnectedFaces())
            connected_IDs -= set(this_shell)
            this_shell.extend(connected_IDs)
        shells.append(this_shell)
        already_sorted |= set(this_shell)
    return shells




On Tuesday, 6 November 2018 02:09:15 UTC+11, Rémi Deletrain wrote:
>
> Hello everyone,
>
> I'm having fun with xGen and his exporter for UnrealEngine.
> I am trying to create the uv mesh it generates. So I made a script that 
> detects each mesh and calculates the position in the UV space.
> Only I have a strange behavior in the UV editor. The indexes are good but 
> the polygons are not correct after the first mesh.
>
> Do you know why?
>
> I enclose my script and scene test in this message.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/31a6c369-1cc8-4343-9418-e751bdb7c34b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to