This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IC > IConstructPoint Interface > IConstructPoint.ConstructOffset Method (ArcObjects .NET 10.5 SDK) |
Constructs a point distance units along the input curve and offset units perpendicularly away from it.
[Visual Basic .NET] Public Sub ConstructOffset ( _ ByVal curve As ICurve, _ ByVal extension As esriSegmentExtension, _ ByVal distance As Double, _ ByVal asRatio As Boolean, _ ByVal Offset As Double _ )
[C#] public void ConstructOffset ( ICurve curve, esriSegmentExtension extension, double distance, bool asRatio, double Offset );
[C++]
HRESULT ConstructOffset(
ICurve* curve,
esriSegmentExtension extension,
double distance,
VARIANT_BOOL asRatio,
double Offset
);
[C++]
Parameters curve
curve is a parameter of type ICurve extension
extension is a parameter of type esriSegmentExtension distance distance is a parameter of type double asRatio asRatio is a parameter of type VARIANT_BOOL Offset Offset is a parameter of type double
A positive Offset distance will create a point on the right side of the curve and a negative offset will create a point on the left side of the curve.
Set the asRatio flag to be True if you want the distance to be a ratio of the curve length. If set to True, then a distance of 0.5 will be equal to half of the curve length (i.e. 50%).
//This example demonstrates how to use IConstructPoint.ConstructOffset method
private void ConstructOffset()
{
IPoint[] points=new IPoint[4];
for (int i=0; i < 4; i++)
{
points[i]=new PointClass();
}
points[0].PutCoords(0, 0);
points[1].PutCoords(10, 0);
points[2].PutCoords(20, 0);
points[3].PutCoords(30, 0);
IPointCollection polyline=new Polyline();
//helper class to solve C-Style Array usage in COM classes
IGeometryBridge geometryBride=new GeometryEnvironmentClass();
geometryBride.AddPoints(polyline as IPointCollection4, ref points);
IConstructPoint constructionPoint=new PointClass();
//The spatial reference should be set on the new point here (Code skipped)
//Example 1: Distance No ratio, Positive offset
constructionPoint.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 15, false, 5);
IPoint outPutPoint1=constructionPoint as IPoint;
System.Windows.Forms.MessageBox.Show("Output point : " + outPutPoint1.X + " , " + outPutPoint1.Y);
//Output point : 15 , -5
//*********************************************
//Example 2: Distance as ratio, Positive offset
constructionPoint.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 0.5, true, 5);
IPoint outPutPoint2=constructionPoint as IPoint;
System.Windows.Forms.MessageBox.Show("Output point : " + outPutPoint2.X + " , " + outPutPoint2.Y);
//Output point : 15 , -5
//*********************************************
//Example 3: Distance No ratio, Negative offset
constructionPoint.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 15, false, -5);
IPoint outPutPoint3=constructionPoint as IPoint;
System.Windows.Forms.MessageBox.Show("Output point : " + outPutPoint3.X + " , " + outPutPoint3.Y);
//Output point : 15 , 5
}
'This example demonstrates how to use IConstructPoint::ConstructOffset
Sub ConstructOffset()
Dim ptc As IPointCollection, pt(3) As IPoint, i As Long
Dim pconsPoint As IConstructPoint, ptout As IPoint
ptc=New Polyline
'The spatial reference should be set on the polyline here (Code skipped)
For i=0 To 3
pt(i)=New Point
Next
pt(0).PutCoords(0, 0)
pt(1).PutCoords(10, 0)
pt(2).PutCoords(20, 0)
pt(3).PutCoords(30, 0)
ptc.AddPoints(4, pt(0))
'The spatial reference should be set on the new point here (Code skipped)
'*********************************************
'Example 1: Distance No ratio, Positive offset
pconsPoint=New Point
pconsPoint.ConstructOffset(ptc, esriSegmentExtension.esriNoExtension, 15, False, 5)
ptout=pconsPoint
Debug.Print("Output point : " & ptout.X & " , " & ptout.Y)
'Output point : 15 , -5
'*********************************************
'Example 2: Distance as ratio, Positive offset
pconsPoint=New Point
pconsPoint.ConstructOffset(ptc, esriSegmentExtension.esriNoExtension, 0.5, True, 5)
ptout=pconsPoint
Debug.Print("Output point : " & ptout.X & " , " & ptout.Y)
'Output point : 15 , -5
'*********************************************
'Example 3: Distance No ratio, Negative offset
pconsPoint=New Point
pconsPoint.ConstructOffset(ptc, esriSegmentExtension.esriNoExtension, 15, False, -5)
ptout=pconsPoint
Debug.Print("Output point : " & ptout.X & " , " & ptout.Y)
'Output point : 15 , 5
End Sub