Offsetting a polyline doubles the segment count

Hi,
I am trying to offset a Polyline inside.
Please refer to the below code.
When I try to Polyline.GetSegmentCount on original and offsetted Polyline - i get twice the count in my offset. Its essentially offsetting and splitting each segment in two halves.
Any thoughts?


    //initialise variables
    double tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    double angleTol = Rhino.RhinoDoc.ActiveDoc.ModelAngleToleranceDegrees;
    AreaMassProperties amp = AreaMassProperties.Compute(OuterBoundary.ToNurbsCurve());
    Point3d centroid = amp.Centroid;


    //offset periphary
    Polyline OffsetBoundary = new Polyline();
    Curve[] offsetBoundary = OuterBoundary.ToNurbsCurve().Offset(new Plane(centroid, Vector3d.ZAxis), -Length, tol, CurveOffsetCornerStyle.Sharp);

    if(offsetBoundary != null && offsetBoundary.Length == 1)
    {
      OffsetBoundary = offsetBoundary[0].ToPolyline(tol, angleTol, 1000.0, 10000000.0).ToPolyline();
    }

Hello,how about this?

if (offsetBoundary != null && offsetBoundary.Length == 1)
{
    offsetBoundary[0].TryGetPolyline(out OffsetBoundary);
}

worked like a charm. Thank you!

1 Like