<?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 Pro and Enumerating Layers: IEnumLayer in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125396#M7476</link>
    <description>&lt;P&gt;I'm combing through ArcPro snippets in GitHub, and I'm still having a very hard time transitioning to the Pro syntax.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It was very simple, in ArcGIS for Desktop, to:&amp;nbsp;&lt;BR /&gt;-create a UID class&lt;BR /&gt;-assign a value&lt;BR /&gt;-enumerate layers, filtering by said UIDClass value&lt;BR /&gt;&lt;BR /&gt;UIDClass uIDClass = new UIDClass();&lt;BR /&gt;uIDClass.Value = "{setValueHere}";&amp;nbsp;&lt;BR /&gt;IEnumLayer layers = Document.FocusMap.get_Layers(uIDClass, true);&lt;BR /&gt;&lt;BR /&gt;In Pro, I'm having the hardest time even finding how to enum layers!&amp;nbsp;&lt;SPAN&gt;I see a LOT about GetLayersAsFlattenedList(), but I can't figure out HOW to use it for my purpose&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Dec 2021 14:03:07 GMT</pubDate>
    <dc:creator>LaurenPeckman</dc:creator>
    <dc:date>2021-12-13T14:03:07Z</dc:date>
    <item>
      <title>Pro and Enumerating Layers: IEnumLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125396#M7476</link>
      <description>&lt;P&gt;I'm combing through ArcPro snippets in GitHub, and I'm still having a very hard time transitioning to the Pro syntax.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It was very simple, in ArcGIS for Desktop, to:&amp;nbsp;&lt;BR /&gt;-create a UID class&lt;BR /&gt;-assign a value&lt;BR /&gt;-enumerate layers, filtering by said UIDClass value&lt;BR /&gt;&lt;BR /&gt;UIDClass uIDClass = new UIDClass();&lt;BR /&gt;uIDClass.Value = "{setValueHere}";&amp;nbsp;&lt;BR /&gt;IEnumLayer layers = Document.FocusMap.get_Layers(uIDClass, true);&lt;BR /&gt;&lt;BR /&gt;In Pro, I'm having the hardest time even finding how to enum layers!&amp;nbsp;&lt;SPAN&gt;I see a LOT about GetLayersAsFlattenedList(), but I can't figure out HOW to use it for my purpose&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 14:03:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125396#M7476</guid>
      <dc:creator>LaurenPeckman</dc:creator>
      <dc:date>2021-12-13T14:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pro and Enumerating Layers: IEnumLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125417#M7477</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;It's very&amp;nbsp; simple in ArcGIS Pro too.&lt;/P&gt;&lt;P&gt;For example you need only feature layers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var featLayers = map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More useful things you can do with linq (do not forget add using System.Linq;)&lt;/P&gt;&lt;P&gt;For example you need to get all feature layers which are named "MyLayer":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var myLayers = map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().Where(x =&amp;gt; string.Compare(x.Name, "MyLayer", true) == 0);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next one all polygon type layers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                    var polygonLayers = map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().Where(
                        l =&amp;gt; l.ShapeType == esriGeometryType.esriGeometryPolygon).ToList();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 15:15:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125417#M7477</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-12-13T15:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pro and Enumerating Layers: IEnumLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125425#M7478</link>
      <description>&lt;P&gt;Thanks for the speedy reply! I have follow-up questions:&lt;BR /&gt;But doesn't your example, var featLayers, only return 1 layer?&amp;nbsp; The first in the flattened list? As it's just assigned as variable var, and not anything explicitly ESRI like IEnumLayer, I suppose I'm still a little unclear on that.&lt;BR /&gt;&lt;BR /&gt;When I try your example, I see that I can somehow select AsEnumerable, and maybe that will do ... something. Whereas, with IEnumLayer, I merely needed ".Next()"&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;And I have absolutely no idea where to find syntax for creating a UIDClass. I'm searching &amp;amp; searching through the API Reference Guide and the Pro Snippets in GitHub, and I'm having a hard time not just flailing about!&lt;BR /&gt;&lt;BR /&gt;Some of the places I've been looking, to find any examples at all of people enumerating layers, or using UIDClass (or whatever the equivalent might be):&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic1.html" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets#mapexploration-snippets" target="_blank"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets#mapexploration-snippets&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 15:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125425#M7478</guid>
      <dc:creator>LaurenPeckman</dc:creator>
      <dc:date>2021-12-13T15:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Pro and Enumerating Layers: IEnumLayer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125482#M7479</link>
      <description>&lt;P&gt;To get one layer you need to use List methods FirstOrDefault or First&amp;nbsp; and you will get one layer:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                var myLayer = map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().Where(x =&amp;gt; string.Compare(x.Name, "MyLayer", true) == 0).FirstOrDefault();&lt;/LI-CODE&gt;&lt;P&gt;Each enumerable you can convert to list using ToList() method. Then you can use all List class methods . Using foreach syntax you can go through list members:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var allFeatLayers = map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().ToList(); 
foreach (var layer in allFeatLayers)
{
    // Do something with layer
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:21:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/pro-and-enumerating-layers-ienumlayer/m-p/1125482#M7479</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-12-13T17:21:23Z</dc:date>
    </item>
  </channel>
</rss>

