This document is archived and information here might be outdated. Recommended version. |
Introduces new vertices into this polyline at specified distances from the beginning of the polyline.
[Visual Basic .NET] Public Function SplitAtDistances ( _ ByVal polyCurve As IPolycurve2, _ ByRef distances As Double[]&, _ ByVal asRatios As Boolean, _ ByVal createParts As Boolean _ ) As IEnumSplitPoint
[C#] public IEnumSplitPoint SplitAtDistances ( IPolycurve2 polyCurve, ref Double[]& distances, ref bool asRatios, ref bool createParts );
[C++]
HRESULT SplitAtDistances(
IPolycurve2* polyCurve,
SAFEARRAY(System.Double)* distances,
VARIANT_BOOL asRatios,
VARIANT_BOOL createParts
);
[C++] Parameters polyCurve [in]
polyCurve is a parameter of type IPolycurve2* distances [in]
distances is a parameter of type SAFEARRAY(double)* asRatios [in]
asRatios is a parameter of type bool createParts [in]
createParts is a parameter of type bool
public void SplitAtDistances()
{
//Construct Polycurve
IPoint fromPoint = new PointClass();
fromPoint.PutCoords(0, 0);
IPoint toPoint = new PointClass();
toPoint.PutCoords(100, 0);
IPolycurve2 polyCurve = new PolylineClass();
polyCurve.FromPoint = fromPoint;
polyCurve.ToPoint = toPoint;
//split in 10 parts using absolute length, therefore asRatio = false
bool asRatio = false;
double[] distances = new double[10];
for (int i = 0; i < 10; i++)
{
distances[i] = (polyCurve.Length / 100) * (i + 1) * 10;
}
IGeometryBridge2 geometryBridge = new GeometryEnvironmentClass();
IEnumSplitPoint splitPoints = geometryBridge.SplitAtDistances(polyCurve, ref distances, asRatio, true);
//print splitPoints
splitPoints.Reset();
IPoint currentPoint;
int partIndex;
int vertexIndex;
splitPoints.Next(out currentPoint, out partIndex, out vertexIndex);
while (currentPoint != null)
{
System.Windows.Forms.MessageBox.Show("X = " + currentPoint.X + " ,Y = " + currentPoint.Y);
splitPoints.Next(out currentPoint, out partIndex, out vertexIndex);
}
}