<?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: Getting MapView from MapFrame in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1537413#M12080</link>
    <description>&lt;P&gt;Sorry, forgot to include that in my post. I'm using Pro 3.3.&lt;/P&gt;&lt;P&gt;Thanks for your suggestion, I will give it a try and post back. My biggest learning curve right now is exactly what you are pointing out, I do not understand very well when a function has to be called with "await" versus not. Haven't been able to wrap my brain around that yet.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2024 16:21:17 GMT</pubDate>
    <dc:creator>CarlosPiccirillo2</dc:creator>
    <dc:date>2024-09-11T16:21:17Z</dc:date>
    <item>
      <title>Getting MapView from MapFrame</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1535130#M12036</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am new to programming ArcGIS Pro SDK with C# but have over 10 years experience in ArcObjects (ArcMap 10.X) with C# and am trying to convert one of our C# scripts that creates maps automatically. I have converted each function from the original code to Pro SDK functions. The code reads a text file to get a permit number and creates a map for that permit. Everything works great on the first permit but as soon as it goes to do the second permit, the code loses its reference to the MapView.&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Using the first example from this ESRI &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic22456.html" target="_blank"&gt;GetMapView Method—ArcGIS Pro&lt;/A&gt;&amp;nbsp;example, I created this function&lt;/P&gt;&lt;P data-unlink="true"&gt;public static MapView SetActiveMapView(Layout pageLayout)&lt;BR /&gt;{&lt;BR /&gt;LayoutView lytView = LayoutView.Active;&lt;BR /&gt;MapFrame mf_bmp = pageLayout.FindElement("LWDD Documents Map") as MapFrame;&lt;BR /&gt;MapView mv_bmp = mf_bmp.GetMapView(lytView);&lt;BR /&gt;return mv_bmp;&lt;BR /&gt;}&lt;/P&gt;&lt;P data-unlink="true"&gt;The code crashes with a "ACCESS DENIED" error on line&amp;nbsp;MapView mv_bmp = mf_bmp.GetMapView(lytView);&lt;/P&gt;&lt;P data-unlink="true"&gt;It's probably something simple since I'm new to ArcGIS Pro SDK but I have been spinning my wheels on this for a couple of weeks and can't get past it. Can anyone point me in the right direction?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 18:10:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1535130#M12036</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-09-04T18:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MapView from MapFrame</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1537396#M12078</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/612984"&gt;@CarlosPiccirillo2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which version of Pro 3x are you on?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The GetMapView method needs to be on the Main CIM thread. It needs to be run under the context of the QueuedTask.&amp;nbsp; Like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//Reference the map frame and its map view
MapFrame mf_bmp = layout.FindElement("Map Frame") as MapFrame;
//On the worker thread
  await QueuedTask.Run(() =&amp;gt;
  {
    MapView mv_bmp = mf_bmp.GetMapView(lytView);
    if (mv_bmp != null) { 
      //Do something with the mapview      
    }
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 16:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1537396#M12078</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2024-09-11T16:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting MapView from MapFrame</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1537413#M12080</link>
      <description>&lt;P&gt;Sorry, forgot to include that in my post. I'm using Pro 3.3.&lt;/P&gt;&lt;P&gt;Thanks for your suggestion, I will give it a try and post back. My biggest learning curve right now is exactly what you are pointing out, I do not understand very well when a function has to be called with "await" versus not. Haven't been able to wrap my brain around that yet.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 16:21:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/getting-mapview-from-mapframe/m-p/1537413#M12080</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-09-11T16:21:17Z</dc:date>
    </item>
  </channel>
</rss>

