<?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: How to determine True visibility of Layer in a map? in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586348#M6422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Ryan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What a great question and something I never considered until just now.&amp;nbsp; I think the only way to test this is to use the Layer.longName property.&amp;nbsp; I hacked together some code below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a function called "IsLayerReallyVisible".&amp;nbsp; I split the longName into a list (of each layer name in the group layer path) and then test each individual layer name.&amp;nbsp; If I find a False, I immediately return that value and exit the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; def IsLayerReallyVisible(mxd, layer): &amp;nbsp; lyrNameList = layer.longName.split("\\") &amp;nbsp; for lyrName in lyrNameList: &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd, lyrName)[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; if not lyr.visible: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False &amp;nbsp; return True&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "US_States")[0] print IsLayerReallyVisible(mxd, lyr)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to learn more about your workflows and if you think it would be necessary to add an enhancement to the API to make this a little more straight forward - or is the code above good enough.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2012 15:35:27 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2012-09-20T15:35:27Z</dc:date>
    <item>
      <title>How to determine True visibility of Layer in a map?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586347#M6421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Before I start trying to write a bunch of code... has anyone figured out how to &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;&lt;STRONG&gt;really&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; determine whether a layer is visible or not in a map? For example, visible (checked) layers within a group layer that is not visible (unchecked) are not truly visible in an MXD.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for lyr in lyrList:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return lyr.visible &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to determine a relationship between a layer and it's parent group it resides in?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The point of this is so we can give a report to the cartography dept and the report will tell them which layers were used, that were truly visible, not just "checked."&amp;nbsp; They make their maps from a list of data sources and layer files, not necessarily the MXD.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 20:33:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586347#M6421</guid>
      <dc:creator>RyanKelley</dc:creator>
      <dc:date>2012-09-19T20:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine True visibility of Layer in a map?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586348#M6422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Ryan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What a great question and something I never considered until just now.&amp;nbsp; I think the only way to test this is to use the Layer.longName property.&amp;nbsp; I hacked together some code below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a function called "IsLayerReallyVisible".&amp;nbsp; I split the longName into a list (of each layer name in the group layer path) and then test each individual layer name.&amp;nbsp; If I find a False, I immediately return that value and exit the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; def IsLayerReallyVisible(mxd, layer): &amp;nbsp; lyrNameList = layer.longName.split("\\") &amp;nbsp; for lyrName in lyrNameList: &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd, lyrName)[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; if not lyr.visible: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False &amp;nbsp; return True&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "US_States")[0] print IsLayerReallyVisible(mxd, lyr)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to learn more about your workflows and if you think it would be necessary to add an enhancement to the API to make this a little more straight forward - or is the code above good enough.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 15:35:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586348#M6422</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-09-20T15:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine True visibility of Layer in a map?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586349#M6423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works just fine IF layers are uniquely named.&amp;nbsp; It would make sense to me to incorporate this all into the API so we don't all have to write out error trapping for dup names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you as always,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 18:02:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586349#M6423</guid>
      <dc:creator>RyanKelley</dc:creator>
      <dc:date>2012-09-20T18:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine True visibility of Layer in a map?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586350#M6424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks for this code which I used today.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the short term, I think the &lt;/SPAN&gt;&lt;STRONG&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s300000008000000"&gt;Layer (arcpy.mapping) documentation&lt;/A&gt;&lt;/STRONG&gt;&lt;SPAN&gt; should be enhanced to mention that the visible property result may be misleading when dealing with Layer Groups, and to have this code mentioned as a workaround.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the medium term, perhaps there can be a new &lt;/SPAN&gt;&lt;STRONG&gt;checkedOn&lt;/STRONG&gt;&lt;SPAN&gt; property added to return True or False irrespective of the Layer Group setting, and the &lt;/SPAN&gt;&lt;STRONG&gt;visible&lt;/STRONG&gt;&lt;SPAN&gt; property behaviour modified to reflect whether the layer really is visible.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Feb 2014 22:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-determine-true-visibility-of-layer-in-a-map/m-p/586350#M6424</guid>
      <dc:creator>GraemeBrowning</dc:creator>
      <dc:date>2014-02-03T22:37:09Z</dc:date>
    </item>
  </channel>
</rss>

