Fastest way to extract faces / separate in maya ?

Skip to first unread message


Jun 23, 2021, 9:10:16 AMJun 23
to Python Programming for Autodesk Maya
Howdy fellas !

I'm working on a project that will need to extract faces (stored in a set) from a combined object, the object has usually more than 500 groups of faces that need to be extracted and separated in an individual mesh, the vertex order need to be preserved.

I did a mockup with cmds, which works and keeps the vertex order for each subelement by simply duplicating the whole object and deleting every face that is not in its correspondent set, but it takes about and hour to process.

duplicated = maya.cmds.duplicate(in_object)[0]

# I take the face start and face end from a selection set
_, face_start, face_end = re.findall(r"[\w.-]+", in_set)

face_start = int(face_start)
face_end = int(face_end)

# This probably is poorly written, but it works to delete every other face that doesn't correspond to the set keeping the vertex order intact.
if face_start > 0 and face_end < max_face:
    maya.cmds.delete(duplicated + ".f[0:%s]" % (face_start - 1),
                                      duplicated + ".f[%s:%s]" % (face_end + 1, max_face))
elif face_start ==0:
    maya.cmds.delete(duplicated + ".f[%s:%s]" % (face_end + `, max_face))

elif face_end == max_face:
    maya.cmds.delete(duplicated + ".f[0:%s]" % (face_start -1))

Any thoughts on this?, 
in the API I saw the extractFaces method but it won't separate it in a different mesh.
Thank you guys !
Reply all
Reply to author
0 new messages