Find a point on a Surface

Hi all,

I’d like to share my solution here.

When looking for a point on a surface we all tend to go for 'Surface.PointAtParameter, u and v both at 0.5) This is fine for simple shapes but not for floorplans. The midpoint of a L-shaped surface lies outside the surface. In older graphs I used to get the polycurve from the perimeter curves. Then offset those 50 and -50. The shortest is inside. Then I took the startpoint and I would have a point to place an Area or a Room. Annoying that it’s so close to the edge but it worked most of the time. When it didn’t I needed to change the offset distance.

Now that I am revising a lot of those graphs I started thinking about this solution. Here is my new workflow: (Numbers correspond with the bullets in the image)
1: get the Surface.PointAtParameter at u=0, v=0
2: get the Surface.PointAtParameter at u=1, v=1
draw a line between them. Now I don’t take the Curve.PointAtParameter yet becouse the midpoint can be outside the surface.
3: Intersect the line and the surface. The result is one or more lines, each line is completely on the surface.
4: I take the one at index 0.
5: Curve.PointAtParameter, param = 0.5

And I get a point ón the surface.