ArcObjects Library Reference  (Geometry)    

ILine_Example

[Visual Basic 6.0]
'+++ This example creates a simple line and gets the angle '+++ and the start and endpoint. Public Sub t_Line() On Error GoTo Errorhandler Dim pLine As ILine Dim pPointFrom As IPoint Dim pPointTo As IPoint Dim dangle As Double Dim dX1 As Double, dY1 As Double Dim dX2 As Double, dY2 As Double Dim pi As Double Set pPointFrom = New Point Set pPointTo = New Point Set pLine = New Line pi = 4 * Atn(1) pPointFrom.PutCoords 100, 100 pPointTo.PutCoords 150, 150 pLine.PutCoords pPointFrom, pPointTo dangle = pLine.Angle * 360 / (2 * pi) pLine.QueryCoords pPointFrom, pPointTo MsgBox pPointFrom.X & "," & pPointFrom.Y & " to " & pPointTo.X & "," & pPointTo.Y _ & vbCrLf & "angle = " & dangle Exit Sub Errorhandler: MsgBox Err.Number & "..." & Err.Description Exit Sub End Sub

[C#]
// This example creates a simple line and gets the angle 
// and the start and endpoint.
public void ShowLineAngle()
{
  IPoint fromPoint = new PointClass();
  fromPoint.PutCoords(100, 100);
  IPoint toPoint = new PointClass();
  toPoint.PutCoords(150, 150);
 
 
  ILine line = new LineClass();
  line.PutCoords(fromPoint, toPoint);
 
 
  double angle = line.Angle;
 
 
  //query Coordinats
  IPoint outFromPoint = new PointClass();
  IPoint outToPoint = new PointClass();
  line.QueryCoords(outFromPoint, outToPoint);
 
 
  System.Windows.Forms.MessageBox.Show("From X = " + outFromPoint.X +
                                       ", From Y = " + outFromPoint.Y + "\n" +
                                       "To X = " + outToPoint.X +
                                       ", To Y = " + outToPoint.Y + "\n" +
                                       "Angle = " + angle);

}


[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.