Getting the Outline of a Surface

Hey,

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.SetCommandPrompt(message);
object_selector.GeometryFilter = ObjectType.Surface();
object_selector.Get();
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.

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_Brep_DuplicateEdgeCurves_1.htm

Here is some sample code that might help you:

https://github.com/mcneel/rhino-developer-samples/blob/master/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateBorder.cs

– 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))
                result.Add(curve);
        }
        return result;
    }

Here’s the result:

Thanks again for your quick help :slight_smile: