Creating a multipoint object from the vertices of a polyline
The following code example creates a multipoint with point elements being copies of the vertices of an existing polyline. It then offsets those elements five units to the right using one transformation method, then offsets them up another five units.
[C#] private void TransformPoint(IPolyline polyline)
{
IPointCollection polylinePoints=polyline as IPointCollection;
IGeometry multipoint=new MultipointClass();
multipoint.SpatialReference=polyline.SpatialReference;
IPointCollection multipointPoints=multipoint as IPointCollection;
//Add copies of the polyline vertices to the multipoint.
multipointPoints.AddPointCollection(polylinePoints);
IAffineTransformation2D affineTransformation=new AffineTransformation2DClass();
affineTransformation.Move(5, 0);
ITransform2D transformee=multipoint as ITransform2D;
transformee.Transform(esriTransformDirection.esriTransformForward,
affineTransformation);
//Shift up by 5.
transformee.Move(0, 5);
transformee.Transform(esriTransformDirection.esriTransformForward,
affineTransformation);
}
[VB.NET] Private Sub TransformPoint(ByVal polyline As IPolyline)
Dim polylinePoints As IPointCollection=CType(polyline, IPointCollection)
Dim multipoint As IGeometry=New MultipointClass()
multipoint.SpatialReference=polyline.SpatialReference
Dim multipointPoints As IPointCollection=CType(multipoint, IPointCollection)
'Add copies of the polyline vertices to the multipoint.
multipointPoints.AddPointCollection(polylinePoints)
Dim affineTransformation As IAffineTransformation2D=New AffineTransformation2DClass()
affineTransformation.Move(5, 0)
Dim transformee As ITransform2D=CType(multipoint, ITransform2D)
transformee.Transform(esriTransformDirection.esriTransformForward, affineTransformation)
'Shift up by 5.
transformee.Move(0, 5)
transformee.Transform(esriTransformDirection.esriTransformForward, affineTransformation)
End Sub
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing | Deployment licensing |
---|---|
ArcGIS Desktop Basic | ArcGIS Desktop Basic |
ArcGIS Desktop Standard | ArcGIS Desktop Standard |
ArcGIS Desktop Advanced | ArcGIS Desktop Advanced |
Engine Developer Kit | Engine |