Re-numbering face index?


#1

Hi guys. I’m wondering if there’s a way to re-number the face index number in a geometry? Either through a pymel/API command or some other method?

Like if I have a face polySurface.f[8] and I want to change it to polySurface.f[0]. Anyway to do this at all?

Thank you in advance for your time :smiley:


#2

This will only work if you either use the python-api and use MFnMesh.createInPlace with the appropriate data (this doesnt change the node, only its shape but breaks undo) or you detach the face and combine the meshes afterward with the face object as first selected object.


#3

[edit] Removing my bad advice :slight_smile: My solution would have reordered vertices, but not faces.

I agree with the post above me. You would need to code this in the API. It wouldn’t be too difficult since it’s just a matter of changing the order in which the faces are specified, but I’m not aware of anything out of the box to do this.


#4

Thank you for sharing your knowledge, zaskar and Keilun. I appreciate it!

I tried seperating the faces and recombining with manual selection and it works. I assume the createInPlace API would work the same.

Thank you, this does give me an option to deal with the issue.

What I was trying to do was re-order a whole surface. A while back, I wrote a script that did a pretty decent job with strips of polygons (looking at neighbouring faces with edge conversion and appending to a list if they share the same edge).

A full surface is…really difficult though. It seems to require a different approach and I have no clue what that can be for the moment.

** Edit to add context, since I have completely left that out:
During modeling the face numbers will get jumbled up as the modeler combines, cuts and delete faces.

I’m trying to put the faces of a surface back into an order that makes sense, for data management purposes.

I made a tool that basically plants geometries on a surface (grass, or what have you) by finding the face center. The thing of course, is the order that maya creates the geometries are then based on the face index, which means face.[0], [1], [2] etc is completely out of order.

it would make things a lot easier if the faces can be reordered in some human-readable way.


#5

Well, I found a way that sort of works. I don’t know if it can be adapted for ALL surfaces of ANY shape, and ordering the list in ANY way you want, but…maybe with a lot of work? I don’t know lol.

Anyhow, you can potentially generate that ordered list, or re-order the face index with the API if you calculate the 3D euclidean distance between the face centers

If you define a start point, you can run a loop to find the closest face center by using the

numpy.linalg.norm(a-b)

function. If you then remove the old start point variable, and use the next closest face center as a new start point, it will move across the surface.

Well, it gave me something I can work with. Not precisely what I want, but enough lol.

If anyone has a better idea, please do share :slight_smile:


#6

if you are looking to match the face order of one mesh to another mesh, there are already tools out there to match vertex ids for blend shapes. they might provide some help on matching face indices.