private void SetInternalInfo(IEnumerable <EntityObject> entities) { bool containsClosedPolyline = false; this.edges.Clear(); foreach (EntityObject entity in entities) { if (containsClosedPolyline) { throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path."); } // it seems that AutoCad does not have problems on creating loops that theoretically does not make sense, like, for example an internal loop that is made of a single arc. // so if AutoCAD is OK with that I am too, the program that make use of this information will take care of this inconsistencies switch (entity.Type) { case EntityType.Arc: this.edges.Add(Arc.ConvertFrom(entity)); break; case EntityType.Circle: this.edges.Add(Arc.ConvertFrom(entity)); break; case EntityType.Ellipse: this.edges.Add(Ellipse.ConvertFrom(entity)); break; case EntityType.Line: this.edges.Add(Line.ConvertFrom(entity)); break; case EntityType.LightWeightPolyline: LwPolyline poly = (LwPolyline)entity; if (poly.IsClosed) { if (this.edges.Count != 0) { throw new ArgumentException("Closed polylines cannot be combined with other entities to make a hatch boundary path."); } this.edges.Add(Polyline.ConvertFrom(entity)); // A polyline HatchBoundaryPath must be closed this.pathType |= HatchBoundaryPathTypeFlags.Polyline; containsClosedPolyline = true; } else { this.SetInternalInfo(poly.Explode()); // open polylines will always be exploded, only one polyline can be present in a path } break; case EntityType.Spline: this.edges.Add(Spline.ConvertFrom(entity)); break; default: throw new ArgumentException(string.Format("The entity type {0} cannot be part of a hatch boundary.", entity.Type)); } } }