I have been wrestling with a problem in Maya for a while, and I cannot find a solution either on or off this site. I made the account so I could pose a direct question to the community and hope to get an answer.
The problem is thus: During modeling, the face index (e.g obj.f[0]) gets jumbled up as a matter of course. I need to re-order that face index sequentially from a user specified start point. This is to put the faces into a selection list. (Maya will put the list based on the face_index number, which is not what we want) To clarify, the face index does not need to be changed itself. It just needs to go into a list properly.
What I did so far: I was able to write some code that will do the selection for a strip of polygons. The face selected gets converted into a list of edges and Maya then searches for faces that shares the same edge and appends that to a new list in order. This works easy in a strip because only one edge is shared for the neighbouring face. Pseudo-code is:
select geo
select start face and make new_list
converts geo_sel into list
for geo_sel_face in geo_sel:
convert to edge
for new_list_face in new_list:
convert to edge
if edge in geo_sel_face in new_list_face:
ordered_list.append(geo_sel_face)
Something like that. Of course the code completely breaks when dealing with a full surface like a plane, since there are at least two edges shared with other faces.
What this is used for: I wrote a script to basically plant grass (or any other type of geometry) across a surface. The original script looks for face centers and plants the grass, or what have you, on the face center. It will also constrain orientation to normals. However, the indexing is jumbled up, and doing additional work that requires a proper index becomes impossible. It would help a lot in data management if the list is human-readable rather than machine readable, which is why I'm searching for a way to do this.
Lastly: I've tried to look for a solution but there doesn't seem any to be found for a full surface. Perhaps I need to think about this from another angle, and would deeply appreciate any help or inspiration from the community.
Thank you for your time!