While this may not exactly answer your question, I’ve always just taken the easy route of:
Duplicate object using cmds.duplicate()
Select all faces on duplicate object
Remove faces you want to keep
Delete remaining faces
That leaves you with a new object and only the faces that you wish to keep. This works really well, though gets a tad bit slow with super dense meshes.
Just create the plane without construction history. From my limited knowledge of the mesh api, maya will freak out if you perform edits directly to a mesh that has history without using a node to perform the edit. If you want to maintain history then you need to write your own node or use the polyChipOff node, which is the node used by Maya to perform any poly extractions/separations/duplications
I’ll probably take the route of jtilden. I don’t want the indices to be changed when duplicating these faces.
Thanks for the help. polyChipOff is kinda slow. I have thousand of super dens meshes, so low execution time is priority.
I can’t find a way to keep the faces together and detach them. (I’m new to the api, any help welcome)
The indices of the existing faces don’t change, the new faces get added at the end of the polygon index range. f[4:5] refers to the newly created faces in that case.
I don’t have a lot of experience with the polygon api, but from what I can tell there is no way to detach faces and have it create a new mesh. You would probably be better off taking the selected faces and using their verts/normals/windings and creating a new mesh with that.
Using jtilden’s method in an MPxCommand would probably be the most straightforward method though.