Getting the Outline of a Surface


I want to get the outlines of a surface in RhinoCommon C#, which is getting me some problems at the moment.

I already got it selected with the GetObject():

GetObject object_selector = new GetObject();
object_selector.GeometryFilter = ObjectType.Surface();
return object_selector.Object(0).Surface;

When selecting the object in Rhino, I get a selection like this:

The Surface I get from Object(0).Surface() however is a rectangle (more exactly a BrepFace):

How can I get the outlines of the first selection?

Thank you a lot for your time.

Brep.DuplicateEdgeCurves sounds like it might be useful for your needs. The link below provides some sample source code as well.

Here is some sample code that might help you:

– Dale

Thanks a lot for your help. I tried out both solutions and got it working now with some tweaking.

What I did was getting all the linear edge curves like in the SampleCsDuplicateBorder (since I only need those) and looked if they are in the BoundingBox I get from the objref.Surface().GetBoundingBox(true):

List FindIntersectingCurves(List curves, Surface surface)

        List<Curve> result = new List<Curve>();
        BoundingBox bbox = surface.GetBoundingBox(true);
        foreach (Curve curve in curves)
            if (bbox.Contains(curve.PointAtStart) && bbox.Contains(curve.PointAtEnd))
        return result;

Here’s the result:

Thanks again for your quick help :slight_smile: