In Edit control points—ArcGIS Pro | Documentation, there is an operation called 'Convert Vertex to Control Point'. How to make it with SDK C# programming.
Because if I want to get the suppress symbol effect in a line feature, it needs control points.(Re: Suppress symbol effect in ArcGIS Pro - Esri Community)
By the way, I am using ArcGIS Pro SDK for .NET 3.0 version, and can it make it or needs higher version?
Solved! Go to Solution.
Hi,
To convert a vertex to a control point, you have to simply change the ID of the vertex from 0 to 1. Control points have a vertex of 1.
So you can iterate through the vertices to find the 4th and 7th vertices.
In the following code snippet, I am changing two vertices in a selected polyline feature to be Control points.
var lineLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
if (lineLayer == null)
return;
var changeVertexIDOperation = new EditOperation();
QueuedTask.Run( () =>
{
var lineLayerCursor = lineLayer.GetSelection().Search();
var lineVertices = new List<MapPoint>();
long oid = -1;
while (lineLayerCursor.MoveNext())
{
var lineFeature = lineLayerCursor.Current as Feature;
var line = lineFeature.GetShape() as Polyline;
int vertexIndex = 1;
oid = lineFeature.GetObjectID();
foreach ( var point in line.Points )
{
MapPointBuilderEx mapPointBuilderEx = new MapPointBuilderEx(point);
//I am changing the vertex 6 and 7 to control points
if (vertexIndex == 6 || vertexIndex == 7)
{
mapPointBuilderEx.HasID = true;
mapPointBuilderEx.ID = 1;
}
lineVertices.Add(mapPointBuilderEx.ToGeometry() as MapPoint);
vertexIndex++;
}
}
var newLine = PolylineBuilderEx.CreatePolyline(lineVertices);
changeVertexIDOperation.Modify(lineLayer, oid, newLine);
changeVertexIDOperation.Execute();
});
All I want to do is as simple as convert the 4th and 7th vertex of a polyline feature to control points. The method you mentioned is a bit complicated for SDK programming, I haven't tried it before, and I'm not sure if it can achieve the same effect.
Hi,
To convert a vertex to a control point, you have to simply change the ID of the vertex from 0 to 1. Control points have a vertex of 1.
So you can iterate through the vertices to find the 4th and 7th vertices.
In the following code snippet, I am changing two vertices in a selected polyline feature to be Control points.
var lineLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
if (lineLayer == null)
return;
var changeVertexIDOperation = new EditOperation();
QueuedTask.Run( () =>
{
var lineLayerCursor = lineLayer.GetSelection().Search();
var lineVertices = new List<MapPoint>();
long oid = -1;
while (lineLayerCursor.MoveNext())
{
var lineFeature = lineLayerCursor.Current as Feature;
var line = lineFeature.GetShape() as Polyline;
int vertexIndex = 1;
oid = lineFeature.GetObjectID();
foreach ( var point in line.Points )
{
MapPointBuilderEx mapPointBuilderEx = new MapPointBuilderEx(point);
//I am changing the vertex 6 and 7 to control points
if (vertexIndex == 6 || vertexIndex == 7)
{
mapPointBuilderEx.HasID = true;
mapPointBuilderEx.ID = 1;
}
lineVertices.Add(mapPointBuilderEx.ToGeometry() as MapPoint);
vertexIndex++;
}
}
var newLine = PolylineBuilderEx.CreatePolyline(lineVertices);
changeVertexIDOperation.Modify(lineLayer, oid, newLine);
changeVertexIDOperation.Execute();
});
U r my hero!