ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / Segment Class / StartPoint Property
Example

In This Topic
    StartPoint Property (Segment)
    In This Topic
    Gets the start point.
    Syntax
    public MapPoint StartPoint {get;}
    Public ReadOnly Property StartPoint As MapPoint
    Example
    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
      Geometry sketchGeometry = polyline; // for example
      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 startPointOfSegment = firsLineSegment.StartPoint;
    }
    Create 3D Polyline and set Z-values while preserving curve segments
    {
      PolylineBuilderEx polylineBuilder = new PolylineBuilderEx(polyline);
      polylineBuilder.HasZ = true;
    
      // The HasZ property is set to true for all the points in
      // polyline3D when you call ToGeometry().
      Polyline polyline3D = polylineBuilder.ToGeometry();
    
      // For this example, create Z-values.
      // You may want to pass them in as a parameter.
      int numPoints = polyline3D.PointCount;
      double[] zValues = new double[numPoints];
      for (int i = 0; i < numPoints; i++)
      {
        zValues[i] = i % 2 == 0 ? 2 : 1;
      }
    
      // We need to know at which point index each part starts
      int partPointIndex = 0;
      int numParts = polyline3D.PartCount;
    
      for (int i = 0; i < numParts; i++)
      {
        var part = polyline3D.Parts[i];
        int numSegmentsInPolyline3D = part.Count;
    
        for (int j = 0; j < numSegmentsInPolyline3D; j++)
        {
          Segment segment = part[j];
    
          MapPointBuilderEx pointBuilder = new MapPointBuilderEx(segment.StartPoint);
          pointBuilder.Z = zValues[partPointIndex++];
          MapPoint startPoint = pointBuilder.ToGeometry();
    
          // Make sure that the end point of this segment is the same as the start point of the next segment
          pointBuilder = new MapPointBuilderEx(segment.EndPoint);
          pointBuilder.Z = zValues[partPointIndex];
          MapPoint endPoint = pointBuilder.ToGeometry();
    
          SegmentType segmentType = segment.SegmentType;
          SegmentBuilderEx segmentBuilder = null;
          switch (segmentType)
          {
            case SegmentType.Line:
              segmentBuilder = new LineBuilderEx((LineSegment)segment);
              break;
            case SegmentType.Bezier:
              segmentBuilder = new CubicBezierBuilderEx((CubicBezierSegment)segment);
              break;
            case SegmentType.EllipticArc:
              segmentBuilder = new EllipticArcBuilderEx((EllipticArcSegment)segment);
              break;
          }
    
          // Only change the start and end point which now have Z-values set.
          // This will preserve the curve if the segment is an EllipticArcSegment or CubicBezierSegment.
          segmentBuilder.StartPoint = startPoint;
          segmentBuilder.EndPoint = endPoint;
          segment = segmentBuilder.ToSegment();
    
          polylineBuilder.ReplaceSegment(i, j, segment);
        }
    
        // Move point index for the next part
        partPointIndex++;
      }
    
      polyline3D = polylineBuilder.ToGeometry();
    }
    Cubic Bezier Properties
    {
      // retrieve the bezier curve's control points
      CubicBezierSegment cb = CubicBezierBuilderEx.CreateCubicBezierSegment(bezierSegment);
      MapPoint startPt = cb.StartPoint;
      Coordinate2D ctrlPt1 = cb.ControlPoint1;
      Coordinate2D ctrlPt2 = cb.ControlPoint2;
      MapPoint endPt = cb.EndPoint;
    
      bool isCurve = cb.IsCurve;
      double len = cb.Length;
    }
    Elliptic Arc Properties
    {
      // retrieve the curve's control points
      EllipticArcSegment arc = EllipticArcBuilderEx.CreateEllipticArcSegment(ellipticArcSegment);
      MapPoint startPt = arc.StartPoint;
      MapPoint endPt = arc.EndPoint;
      Coordinate2D centerPt = arc.CenterPoint;
      bool isCircular = arc.IsCircular;
      bool isMinor = arc.IsMinor;
      bool isCounterClockwise = arc.IsCounterClockwise;
      bool isCurve = arc.IsCurve;
      double len = arc.Length;
      double ratio = arc.MinorMajorRatio;
    
      double semiMajorAxis, semiMinorAxis;
      // get the axes
      arc.GetAxes(out semiMajorAxis, out semiMinorAxis);
      // or use the properties
      // semiMajorAxis = arc.SemiMajorAxis;
      // semiMinorAxis = arc.SemiMinorAxis;
    
      double startAngle, centralAngle, rotationAngle;
      // or use QueryCoords to get complete information
      arc.QueryCoords(out centerPt, out startAngle, out centralAngle, out rotationAngle, out semiMajorAxis, out semiMinorAxis);
    
      // use properties to get angle information
      //double endAngle = arc.EndAngle;
      //centralAngle = arc.CentralAngle;
      //rotationAngle = arc.RotationAngle;
      //startAngle = arc.StartAngle;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also