Select to view content in your preferred language

How to replace sketch geometry in a MapTool

321
0
11-15-2024 03:16 AM
MarkMindlin_idea
Regular Contributor

We are creating a custom Map Tool. Two sketches should be drawn one after another.

- First sketch should be drawn by a user;

- Second sketch should be drawn programmatically and should start at the position of the first sketch centre

When user does the first sketch mouse up, we have OnToolMouseUp method. We get a sketch geometry and coordinates for the second sketch, then change the sketchType (from Rectangle to Circle) , create a circle geometry and set geometry.

 

Question: how to make the second sketch visible?

ArcGIS Pro 3.4, .NET 8

 

 

 

 

protected async override void OnToolMouseUp(MapViewMouseButtonEventArgs args)
{
    await QueuedTask.Run(() =>
    {
        FireSketchEvents = true;
        ArcGIS.Core.Geometry.Geometry currentSketchGeometry = null;
        currentSketchGeometry = this.GetCurrentSketchAsync().Result;
        if (currentSketchGeometry.PointCount < 5)
        {  clsShare.MessageBoxShow("Cannot proceed without rectangle selection"); }
        Coordinate2D secondSketchCentrePoint = // here the point calculated

        EllipticArcSegment segment = new ArcGIS.Core.Geometry.EllipticArcBuilderEx(secondSketchCentrePoint,1,ArcOrientation.ArcCounterClockwise).ToSegment();
        ArcGIS.Core.Geometry.Polygon polylineNewSketchGeometry = PolygonBuilderEx.CreatePolygon([segment]);

        //this.ClearSketchAsync();
        //base.OnToolMouseUp(args);
        this.SketchType = SketchGeometryType.Circle;
        this.SetCurrentSketchAsync(polylineNewSketchGeometry);
        this.StartSketchAsync();
        args.Handled = true;
    });

 

 

 

 

 

Tags (3)
0 Kudos
0 Replies