How to reorder Brep edge indices to match a baseline Brep using RhinoComm

Hello,

I have a single NURBS surface (Brep) in Rhino, and a reference surface obtained from it by exporting and then re-importing. These two surfaces are geometrically identical — they have the same shape, size, position, and number of edges. However, the order of the edge indices (Brep.Edges) differs between the original and the reference surface.

For my workflow, it’s important that the edge indices of the original surface are ordered exactly as they are in the reference surface — essentially, as they appear after exporting and importing. Currently, even though the geometry is identical, the same physical edge has different indices in each surface.

Exporting and re-importing the surface as STEP or IGES files solves the problem — the edge indices become consistent. However, I would prefer a solution that does not involve exporting and importing, ideally using Rhino tools or scripting via RhinoCommon (Python).

I have tried using Rhino commands like Reparameterize and RebuildEdges, but they do not affect the edge order. I have also written Python scripts with RhinoCommon to inspect and compare Brep.Edges and attempted to rebuild the surface using EdgeSrf by providing the edges in the desired order. I also looked for ways to manually reassign edge indices via the API.

So far, none of these approaches have worked — the edge indices do not match.

My question is: Is there a way — either in Rhino or through RhinoCommon/Python — to reorder or rebuild the edges of a Brep so their indices match the reference surface?

Thank you in advance.

Best regards,
leex