ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / Multipart Class / Points Property
Example

In This Topic
    Points Property (Multipart)
    In This Topic
    Gets a collection of points representing the vertices of all the parts.
    Syntax
    public ReadOnlyPointCollection Points {get;}
    Public ReadOnly Property Points As ReadOnlyPointCollection
    Example
    Get the points of a Polyline
    // get the points as a readonly Collection
    ReadOnlyPointCollection pts = polyline.Points;
    int numPts = polyline.PointCount;
    
    // OR   get an enumeration of the points
    IEnumerator<MapPoint> enumPts = polyline.Points.GetEnumerator();
    
    // OR   get the point coordinates as a readonly list of Coordinate2D
    IReadOnlyList<Coordinate2D> coordinates = polyline.Copy2DCoordinatesToList();
    
    // OR   get the point coordinates as a readonly list of Coordinate3D
    IReadOnlyList<Coordinate3D> coordinates3D = polyline.Copy3DCoordinatesToList();
    
    // OR   get a subset of the collection as Coordinate2D using preallocated memory
    
    IList<Coordinate2D> coordinate2Ds = new List<Coordinate2D>(10);   // allocate some space
    ICollection<Coordinate2D> subsetCoordinates2D = coordinate2Ds;    // assign
    pts.Copy2DCoordinatesToList(1, 2, ref subsetCoordinates2D);       // copy 2 elements from index 1 into the allocated list
                                                                      // coordinate2Ds.Count = 2
                                                                      // do something with the coordinate2Ds
    
    // without allocating more space, obtain a different set of coordinates
    pts.Copy2DCoordinatesToList(5, 9, ref subsetCoordinates2D);       // copy 9 elements from index 5 into the allocated list
                                                                      // coordinate2Ds.Count = 9
    
    
    // OR   get a subset of the collection as Coordinate3D using preallocated memory
    
    IList<Coordinate3D> coordinate3Ds = new List<Coordinate3D>(15);   // allocate some space
    ICollection<Coordinate3D> subsetCoordinates3D = coordinate3Ds;    // assign
    pts.Copy3DCoordinatesToList(3, 5, ref subsetCoordinates3D);       // copy 5 elements from index 3 into the allocated list
                                                                      // coordinate3Ds.Count = 5
    
    
    // OR   get a subset of the collection as MapPoint using preallocated memory
    
    IList<MapPoint> mapPoints = new List<MapPoint>(7);   // allocate some space
    ICollection<MapPoint> subsetMapPoint = mapPoints;    // assign
    pts.CopyPointsToList(1, 4, ref subsetMapPoint);      // copy 4 elements from index 1 into the allocated list
                                                         // mapPoints.Count = 4
    
    StartPoint of a Polyline
    // Method 1: Get the start point of the polyline by converting the polyline 
    //    into a collection of points and getting the first point
    
    // sketchGeometry is a Polyline
    // get the sketch as a point collection
    var pointCol = ((Multipart)sketchGeometry).Points;
    // Get the start point of the line
    var firstPoint = pointCol[0];
    
    // Method 2: Convert polyline into a collection of line segments 
    //   and get the "StartPoint" of the first line segment.
    var polylineGeom = sketchGeometry as ArcGIS.Core.Geometry.Polyline;
    var polyLineParts = polylineGeom.Parts;
    
    ReadOnlySegmentCollection polylineSegments = polyLineParts.First();
    
    //get the first segment as a LineSegment
    var firsLineSegment = polylineSegments.First() as LineSegment;
    
    //Now get the start Point
    var startPoint = firsLineSegment.StartPoint;
    
    Get the points of a Polygon
    // get the points as a readonly Collection
    ReadOnlyPointCollection pts = polygon.Points;
    
    // get an enumeration of the points
    IEnumerator<MapPoint> enumPts = polygon.Points.GetEnumerator();
    
    // get the point coordinates as a readonly list of Coordinate2D
    IReadOnlyList<Coordinate2D> coordinates = polygon.Copy2DCoordinatesToList();
    
    // get the point coordinates as a readonly list of Coordinate3D
    IReadOnlyList<Coordinate3D> coordinates3D = polygon.Copy3DCoordinatesToList();
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also