<?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: ArcGIS Pro Get Active Layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045925#M60742</link>
    <description>&lt;P&gt;Could you explain what you mean by "active layer"? Do you mean the layer that was last clicked by the user in the table of content and that is highlighted in blue? Or are you looking for layers that are visible (checkbox checked)?&lt;/P&gt;</description>
    <pubDate>Mon, 12 Apr 2021 14:48:00 GMT</pubDate>
    <dc:creator>DavidBlanchard</dc:creator>
    <dc:date>2021-04-12T14:48:00Z</dc:date>
    <item>
      <title>ArcGIS Pro Get Active Layer</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045183#M60719</link>
      <description>&lt;P&gt;In Python ArcGIS Pro 2.7, I'm trying to get the active layer in a Map TOC.&amp;nbsp; I can get the CURRENT project and active map, but I've met my threshold to get the active layer in the map.&amp;nbsp; I thought it might be a property of listlayers or even the active map, but not the case.&lt;/P&gt;&lt;P&gt;Here is a part of my code.&amp;nbsp; Ultimately, I'm trying to get the active layer and pass a Definition Query to it.&amp;nbsp; Below I have the layer in question (&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;County&lt;/FONT&gt;&lt;/STRONG&gt;) hardcoded, but I want to replace this with the active layer variable. After I get the lyr, then I build a Def Query using pre-defined input.&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;currentmap = aprx.activeMap&lt;BR /&gt;lyr = currentmap.listLayers("&lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;County&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;")[0]&lt;/P&gt;&lt;P&gt;qry = '\"%s\" = \'%s\'' %(in1,in2)&lt;BR /&gt;lyr.definitionQuery = qry&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 18:10:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045183#M60719</guid>
      <dc:creator>Darrin_Smith</dc:creator>
      <dc:date>2021-04-08T18:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Get Active Layer</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045925#M60742</link>
      <description>&lt;P&gt;Could you explain what you mean by "active layer"? Do you mean the layer that was last clicked by the user in the table of content and that is highlighted in blue? Or are you looking for layers that are visible (checkbox checked)?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 14:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045925#M60742</guid>
      <dc:creator>DavidBlanchard</dc:creator>
      <dc:date>2021-04-12T14:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Get Active Layer</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045939#M60743</link>
      <description>&lt;P&gt;Yes it the blue highlighted layer in the Table of Contents.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 15:05:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045939#M60743</guid>
      <dc:creator>Darrin_Smith</dc:creator>
      <dc:date>2021-04-12T15:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Get Active Layer</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045970#M60745</link>
      <description>&lt;P&gt;I don't believe this is possible in the current release of ArcPro. What you see in the TOC is a node in a tree view, which you are interpreting as a layer in the map. I assume its a treeview, I don't actually know, but either way its a "thing" you interact with on the main application interface. So being selected is not a property of a layer that you can query or use in python/arcpy.&lt;/P&gt;&lt;P&gt;If you were using ArcMap you could get to that vital bit of information, this is discussed &lt;A href="https://community.esri.com/t5/python-questions/get-currently-selected-layer-in-arcmap-table-of-contents/m-p/369530" target="_self"&gt;here.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you have the skills and were willing to create an add in using say VB or c# you can also get to that information using code as discussed &lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-access-currently-selected-datasource-from-pro-sdk/td-p/830941" target="_self"&gt;here.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It's not even exposed using the CIM module.&lt;/P&gt;&lt;P&gt;So suggest it as an idea, I would vote for it!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 15:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1045970#M60745</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-04-12T15:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Get Active Layer</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1046025#M60747</link>
      <description>&lt;P&gt;That's unfortunate.&amp;nbsp; I used to do this quite often in VBA with ArcMap.&amp;nbsp; It really opens up your options for scripting.&amp;nbsp; It's interesting how the fundamentals of Pro (from the contextual menu perspective) must work regarding the Tree View?&amp;nbsp; This applies even down to the Geoprocessing tool level as well.&amp;nbsp; For example the Select by Location tool will automatically know which layer is TOC highlighted/selected and pre-populate the input.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 18:10:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-get-active-layer/m-p/1046025#M60747</guid>
      <dc:creator>Darrin_Smith</dc:creator>
      <dc:date>2021-04-12T18:10:26Z</dc:date>
    </item>
  </channel>
</rss>

