I want to sort a group of meshes in clockwise or counterclockwise order in a three-dimensional space. I’d like to use the “Plane.FitPlaneToPoints ()” of the face center point as the reference plane for sorting them in either clockwise or counterclockwise order. Then, I want to draw a polyline that won’t intersect itself after projecting it onto the FitPlane.

My current method is as follows:

The “DataTree” is set up using a list of points generated from any arbitrary point on the mesh.

The method “Mesh.Faces.GetFaceCenter (faceID)” is used to find the center point.

The method “Plane.FitPlaneToPoints (CenterPoint's collection, out plane)” is used to find the FITPlane.

The “Transform.PlaneToPlane” method is used to move the entire group of points to the origin of the world, and the X and Y coordinates of the points are then determined.

The “Math.Acos” method is used to find the angle, and the Y value is used to determine its sign.

The central points of the meshes are sorted according to the angle obtained in step 4, using the “System.Array.Sort” method.

Although this method produces my desired result, I was wondering if there is a more elegant approach? (My computer doesn’t run fast enough…)

RC provides a suitable Method for that (MTV.SortEdges() - where MTV is the MeshTopologyVertex List). If this is what you are after I could provide an entry level take on that matter. That said MTV indexing (vertices on a per Mesh basis) is NOT the same as MV indexing (vertices on a per MeshFace basis) … but there’s RC Methods to “map” indices both ways.

BTW: Obviously you should take into account naked stuff (for more than obvious reasons). I do hope that you are familiar with basic Mesh Connectivity (V/E/F) matters - you can do 7 out of the 9 Conn Trees (VV, VE, VF … blah, blah) via available RC Methods.