/// <summary> /// 由线转为面 /// </summary> /// <param name="pPolyline"></param> /// <returns></returns> private IPolygon PolyLineToPolygon(IPolyline pPolyline) { object obj = Type.Missing; IClone pClonepPolyline = pPolyline as IClone; try { // 闭合线 if (pPolyline.IsClosed) { ISegmentCollection pPolylineSegment = pClonepPolyline.Clone() as ISegmentCollection; ISegmentCollection pPolygonSegment = new PolygonClass(); for (int i = 0; i < pPolylineSegment.SegmentCount; i++) { pPolygonSegment.AddSegment( pPolylineSegment.get_Segment(i), ref obj, ref obj); } return pPolygonSegment as IPolygon; } // 非闭合线 else { IPointCollection pPolylinePoint = pClonepPolyline.Clone() as IPointCollection; IPointCollection pPolygonPoint = new PolygonClass(); for (int i = 0; i < pPolylinePoint.PointCount; i++) { pPolygonPoint.AddPoint( pPolylinePoint.get_Point(i), ref obj, ref obj); } IPolygon pPolygon = pPolygonPoint as IPolygon; //pPolygon.Close(); return pPolygonPoint as IPolygon; } } catch (Exception exc) { Console.WriteLine(exc.Message); return null; } }