Most efficient way to draw Obround (Oblong)

Hi All,

Just want to find out what is the most efficient method to draw an Obround shape using RhinoCommon (C#).

I will have to draw thousands of them. Currently, I can draw a rectangle, then do a Chamfer curve with the radius of the width / 2. If there is some more efficient way, please let me know.

1 Like

This is my code on drawing a generic Obround with the centre point, my question is, is there any predefined method?

  public override Result drawObround(Point3d point3d)
  {
     Point3d leftPoint = new Point3d(point3d.X - (this.X/2) + (Y/2), point3d.Y,0);
     Point3d rightPoint = new Point3d(point3d.X + (this.X/2) - (Y/2), point3d.Y,0);

     Arc leftCircle = new Arc(new Circle(leftPoint, Y / 2), Math.PI);
     leftCircle.StartAngle = Math.PI / 2;
     leftCircle.EndAngle = 3 * Math.PI / 2;

     Arc rightCircle = new Arc(new Circle(rightPoint, Y / 2), Math.PI);
     rightCircle.StartAngle = -Math.PI / 2;
     rightCircle.EndAngle = Math.PI / 2;

     Line top = new Line(point3d.X - (this.X / 2) + (Y / 2), point3d.Y + Y / 2, 0, point3d.X + (this.X / 2) - (Y / 2), point3d.Y + Y / 2, 0);
     Line bottom = new Line(point3d.X - (this.X / 2) + (Y / 2), point3d.Y - Y / 2, 0, point3d.X + (this.X / 2) - (Y / 2), point3d.Y - Y / 2, 0);

     RhinoDoc.ActiveDoc.Objects.AddArc(leftCircle);
     RhinoDoc.ActiveDoc.Objects.AddArc(rightCircle);
     RhinoDoc.ActiveDoc.Objects.AddLine(top);
     RhinoDoc.ActiveDoc.Objects.AddLine(bottom);


     return Result.Success;
  }

Hi Toby,

RhinoCommon does not have a method to create a curve as you depict.

My only suggestion with your code is to create a single polycurve from the four curve segments, instead of adding each curve segment to the document one-by-one.