<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating Buffer Based on User Defined Point in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-buffer-based-on-user-defined-point/m-p/1399071#M11263</link>
    <description>&lt;P&gt;As an update - I managed to get this working this morning. I found the code snippet here -&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Geoprocessing/GeoprocessingExecuteAsync/BufferGeometryTool.cs" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Geoprocessing/GeoprocessingExecuteAsync/BufferGeometryTool.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I updated the script and it looks like this now and seems to be working like I need it to!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;namespace Tester
{
    internal class MapTool1 : MapTool
    {
        public MapTool1()
        {
            IsSketchTool = true;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        // This happens before the tool is run //
        protected override Task OnToolActivateAsync(bool active)
        {
            MessageBox.Show(
                "Please Select a Point on the Map!"
            );


            return base.OnToolActivateAsync(active);
        }

        //This happens when the user clicks and begins to use the tool
        protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
        {
            var valueArray = await QueuedTask.Run(() =&amp;gt;
            {
                var g = new List&amp;lt;object&amp;gt;() { geometry, };
                // Creates a 2 mile buffer around the geometry object
                // null indicates a default output name is used
                return Geoprocessing.MakeValueArray(g, null, @"2 Miles");
            });

            await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray);
            return true;
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 15:42:10 GMT</pubDate>
    <dc:creator>jjackson229</dc:creator>
    <dc:date>2024-03-21T15:42:10Z</dc:date>
    <item>
      <title>Creating Buffer Based on User Defined Point</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-buffer-based-on-user-defined-point/m-p/1398701#M11257</link>
      <description>&lt;P&gt;Hi everyone! I am super new to SDK, so there may be an obvious answer. Is there a way for a user to select a point on a map and then that point is buffered a set distance? I'm using Visual Studio 2022, and the ArcGIS Pro Module Add-in (C#).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've looked at the pro snippets to buffer a MapPoint on the&amp;nbsp;GitHub, but I'm just not connecting the dots on it.&amp;nbsp; I've been able to set it so a user can select a point on the map and it shows the coordinates in a message box, and have an initial message box pop up prompting the user to select a point, I've just been running into issues getting a buffer to work. I've included my code down below, thanks for any advice!&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;namespace Tester
{
    internal class MapTool1 : MapTool
    {
        public MapTool1()
        {
            IsSketchTool = true;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        // This happens before the tool is run //
        protected override Task OnToolActivateAsync(bool active)
        {
            MessageBox.Show(
                "Please Select a Point on the Map!"
            );

            MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
            Geometry ptBuffer = GeometryEngine.Instance.Buffer(pt, 5.0);
            Polygon buffer = ptBuffer as Polygon;

            return base.OnToolActivateAsync(active);
        }

        //This happens when the user clicks and begins to use the tool
        protected override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
        {

            MessageBox.Show(
                "North: " + geometry.Extent.YMax.ToString() + "\n" +
                "South: " + geometry.Extent.YMin.ToString() + "\n" +
                "East: " + geometry.Extent.XMax.ToString() + "\n" +
                "West: " + geometry.Extent.XMin.ToString()
            );


             MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReference.WGS84);
             Geometry ptBuffer = GeometryEngine.Instance.Buffer(pt, 5.0);
            Polygon buffer = ptBuffer as Polygon;

      
          
            return base.OnSketchCompleteAsync(geometry);
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 20:01:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-buffer-based-on-user-defined-point/m-p/1398701#M11257</guid>
      <dc:creator>jjackson229</dc:creator>
      <dc:date>2024-03-20T20:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Buffer Based on User Defined Point</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-buffer-based-on-user-defined-point/m-p/1399071#M11263</link>
      <description>&lt;P&gt;As an update - I managed to get this working this morning. I found the code snippet here -&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Geoprocessing/GeoprocessingExecuteAsync/BufferGeometryTool.cs" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Geoprocessing/GeoprocessingExecuteAsync/BufferGeometryTool.cs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I updated the script and it looks like this now and seems to be working like I need it to!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;namespace Tester
{
    internal class MapTool1 : MapTool
    {
        public MapTool1()
        {
            IsSketchTool = true;
            SketchType = SketchGeometryType.Point;
            SketchOutputMode = SketchOutputMode.Map;
        }

        // This happens before the tool is run //
        protected override Task OnToolActivateAsync(bool active)
        {
            MessageBox.Show(
                "Please Select a Point on the Map!"
            );


            return base.OnToolActivateAsync(active);
        }

        //This happens when the user clicks and begins to use the tool
        protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
        {
            var valueArray = await QueuedTask.Run(() =&amp;gt;
            {
                var g = new List&amp;lt;object&amp;gt;() { geometry, };
                // Creates a 2 mile buffer around the geometry object
                // null indicates a default output name is used
                return Geoprocessing.MakeValueArray(g, null, @"2 Miles");
            });

            await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray);
            return true;
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:42:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/creating-buffer-based-on-user-defined-point/m-p/1399071#M11263</guid>
      <dc:creator>jjackson229</dc:creator>
      <dc:date>2024-03-21T15:42:10Z</dc:date>
    </item>
  </channel>
</rss>

