Inconsistent Behavior of GetOffsetCurves() with Positive Offset — Outside Offset Not Guaranteed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm experiencing inconsistent behavior with the GetOffsetCurves() method in the AutoCAD .NET API when applying a positive offset to a Polyline.
In most cases, the positive offset correctly creates an outside offset, but in some cases, it unexpectedly creates an inside offset, even though the polylines are closed and appear to have consistent structure and direction.
My requirement is to always create an offset on the outside of the closed polyline, regardless of its orientation or how it was drawn.
Please check below code:
public Polyline ApplyObstacleOffset(Transaction tr, Polyline polyline , BlockTableRecord space, double BOffset)
{
Polyline updated = null;
if (polyline != null)
{
DBObjectCollection offsetCurves = polyline.GetOffsetCurves(BOffset);
foreach (DBObject obj in offsetCurves)
{
Polyline offsetPolyline = obj as Polyline;
if (offsetPolyline != null)
{
space.AppendEntity(offsetPolyline);
tr.AddNewlyCreatedDBObject(offsetPolyline, true);
}
updated = offsetPolyline;
}
}
return updated;
}