<?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: Get the geometry from a maptool in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1688926#M102237</link>
    <description>&lt;P&gt;It appeared to be easier than I thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a custom event, and in my maptool, I added these two lines in the OnSketchCompleted method:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var payload = new SketchFinishedEventArgs(geometry);
SketchFinishedEvent.Publish(payload);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the form, I keep track of the current (and previous) tool, using the&amp;nbsp;ActiveToolChangedEvent:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;_currentToolId = args.CurrentID;
_previousToolId = args.PreviousID;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The form also listens to my custom event:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async Task SketchFinished(SketchFinishedEventArgs args)
{
    // Only act if MyTool published this event
    if (_currentToolId == "MyTool")
    {
        _line = args.Sketch as Polyline;
        // activate whatever the previous tool was
        await FrameworkApplication.SetCurrentToolAsync(_previousToolId);         
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Mar 2026 11:57:00 GMT</pubDate>
    <dc:creator>BerendVeldkamp</dc:creator>
    <dc:date>2026-03-06T11:57:00Z</dc:date>
    <item>
      <title>Get the geometry from a maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1688913#M102235</link>
      <description>&lt;P&gt;I am writing an add-in for Pro. This add-in contains a form with a button that activates a custom maptool, i.e.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await FrameworkApplication.SetCurrentToolAsync("MyTool");&lt;/LI-CODE&gt;&lt;P&gt;This works, and I can sketch a geometry on the map.&lt;/P&gt;&lt;P&gt;How do I get a reference to the geometry in the form? Do I need to fire a custom event from the maptool's&amp;nbsp;OnSketchCompleteAsync method? Or can I somehow reuse the existing&amp;nbsp;SketchCompletedEvent event?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2026 11:57:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1688913#M102235</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2026-03-06T11:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get the geometry from a maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1688926#M102237</link>
      <description>&lt;P&gt;It appeared to be easier than I thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a custom event, and in my maptool, I added these two lines in the OnSketchCompleted method:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var payload = new SketchFinishedEventArgs(geometry);
SketchFinishedEvent.Publish(payload);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the form, I keep track of the current (and previous) tool, using the&amp;nbsp;ActiveToolChangedEvent:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;_currentToolId = args.CurrentID;
_previousToolId = args.PreviousID;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The form also listens to my custom event:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async Task SketchFinished(SketchFinishedEventArgs args)
{
    // Only act if MyTool published this event
    if (_currentToolId == "MyTool")
    {
        _line = args.Sketch as Polyline;
        // activate whatever the previous tool was
        await FrameworkApplication.SetCurrentToolAsync(_previousToolId);         
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2026 11:57:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1688926#M102237</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2026-03-06T11:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get the geometry from a maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1689008#M102238</link>
      <description>&lt;P&gt;There are several options for this, one would be to create the graphics layers BEFORE you run the custom&lt;/P&gt;&lt;P&gt;the tool so you can grab a handle to the layer AFTER you return from await. Assumption here is you are using the same map. This would work with any specific layer in the map., I'm just assuming you are drawing on the graphics layer.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// get params&lt;BR /&gt;var map = MapView.Active.Map;&lt;BR /&gt;var layerParams = new LayerCreationParams("My New Graphics Layer");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// create graphics layer&lt;BR /&gt;GraphicsLayer newLayer = LayerFactory.Instance.CreateLayer(layerParams, map , LayerPosition.AddToTop);&lt;/P&gt;&lt;P&gt;Bool success=false;&lt;BR /&gt;success = await myTask(my variables);&lt;BR /&gt;// Find the first graphics layer in the map if we returned from the task without error&lt;BR /&gt;If (success==true)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; var graphicsLayer = map.GetLayersAsFlattenedList().OfType().FirstOrDefault();&lt;BR /&gt;&amp;nbsp; ... do more stuff ...&lt;/P&gt;&lt;P&gt;or use&amp;nbsp;newLayer&amp;nbsp;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of note, at ArcGIS Pro 3.4 maps started having a default graphics layer. This means you can grab that instead of creating your own layer (but since you are working with a custom tool, having your OWN graphics layer would have value).&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;// Get the first available GraphicsLayer in the map&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;var&lt;/SPAN&gt;&lt;SPAN class=""&gt; graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                                .OfType&amp;lt;GraphicsLayer&amp;gt;().FirstOrDefault();&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2026 17:20:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/get-the-geometry-from-a-maptool/m-p/1689008#M102238</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2026-03-06T17:20:54Z</dc:date>
    </item>
  </channel>
</rss>

