I’m trying to separately extract the coordinates of the vertices of the faces of a closed polysurface. Just imagine a cube, where for each of the six sides I would like to put out the coordinates of its 4 corner points, arranged clockwise/counter-clockwise with respect to the surface normal:
I have tried to access this information via the edge-list of the faces and their PointAtStart and PointAtEnd properties, but unfortunately there seems to be no information on their order, so that I don’t know how to arrange them properly. Since Rhino needs the information on what is “outside” with respect to the polysurface, I was hoping that this data (the right order of the points) was already computed somewhere.
I thought that maybe the Face.Outerloop structure could help, but don’t quite understand what it does. Looking through online examples I tried to trim the outer loop and use the PointAtStart etc. of the trims, but those coordinates didn’t match with the “real” ones.
Thanks, I’ll try to work through that. Meanwhile, I have decided to just order the surface points based on the surface normal, which seems to work fine in 99% of cases.
One quick question: Is the face normal really not necessarily the same as the surface normal as suggested by the image you’ve posted? I’m asking, because for those non-working 1% of cases I have found that the direction of the face normal is wrong, e.g. pointing inside the block.
Thanks again!
EDIT:
Found the error in my code, I was looking at the wrong u-v-values for the face normal. Thread can be closed.
For anyone interested in my not-so-quick&dirty solution: Fill an array with all face vertices and bubblesort them clockwise by evaluating n*((a-center) X (b-center)), where n is the normal vector, c the face center and a and b the vertices to check.
Yes it is possible that the face normal is inverted w.r.t. the underlying surface normal. In that case BrepFace.OrientationIsReversed is true. This is typically the result of a Flip, Dir or Join command and can be seen by the small, purple line opposite of the face normal when using Dir command.