<?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: Layer Visible in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634758#M49438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see the documentation says that works, but I have had issues in the past.&lt;/P&gt;&lt;P&gt;Would not let me get the dataframe unless I either hard coded the name, or used the "*".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was in earlier version.&amp;nbsp; Maybe I can test again now that I'm running 10.2.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the feedback,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just tested in 10.2.1 and the empty string seems to work fine now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Jul 2017 17:49:25 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2017-07-27T17:49:25Z</dc:date>
    <item>
      <title>Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634752#M49432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to turn a layer on in the Layer of Contents via a python script. When I execute the script below either as a script&amp;nbsp;tool in ArcToolbox or via the python window in ArcMap the visibility status changes in the layer properties but the layer does not turn on in the Table of Contents and the layer does not draw in the data view window. I execute this script within ArcMap and have layers in the Table of Contents which are currently turned off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;# Import arcpy module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;df = arcpy.mapping.ListDataFrames(mxd, "")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;for lyr in arcpy.mapping.ListLayers(mxd, "", df):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.visible =&amp;nbsp;True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;arcpy.RefreshTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 01:32:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634752#M49432</guid>
      <dc:creator>DaveMarkey</dc:creator>
      <dc:date>2017-07-27T01:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634753#M49433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What version of ArcMap are you using?&amp;nbsp; Do you have more than 1 Data Frame?&amp;nbsp; If so, is the active frame the one you are trying to manipulate?&amp;nbsp; What does your layer structure look like?&amp;nbsp; Do you have nested/group layers?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 03:08:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634753#M49433</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-07-27T03:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634754#M49434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For one, unless you have a data frame named "", it will not get the proper value for df.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe try:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Import arcpy module&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sys
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os

mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Layers"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;visible &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshTOC&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or whatever your data frame name is if it is not "Layers".&lt;/P&gt;&lt;P&gt;At least for me.&amp;nbsp; The documentation suggests that it should work, but I have always had to put the df name in there.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;R_&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:59:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634754#M49434</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T02:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634755#M49435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Conversly they could just use "*" as the input which would just be a wildcard for every possible string and should return a list of all dataframes in the map document.&amp;nbsp; Using an empty string like they did would not return any dataframes unless the dataframe was unnamed like you mentioned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df &lt;SPAN&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN&gt;.&lt;/SPAN&gt;mapping&lt;SPAN&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN&gt;(&lt;/SPAN&gt;mxd&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;"*"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 15:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634755#M49435</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-07-27T15:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634756#M49436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ian and Rhett, in this case the empty string works fine and will return all the data frames.&amp;nbsp; It isn't that an empty string is an Esri wildcard, like "*", an empty string is a Python wildcard of sorts.&amp;nbsp; When using find with Python strings or search with Python regular expressions, an empty string is found immediately so every data frame is returned because an empty string is found within every string representing data frame names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example from an newly created MXD where I insert a new/second data frame using default values:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; df &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
Layers
New Data Frame
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:00:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634756#M49436</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T03:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634757#M49437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have tried the OP's code, and it seems to work. It could be the visibility scale or one of the items &lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;‌ is asking about in his first post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 17:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634757#M49437</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-07-27T17:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Layer Visible</title>
      <link>https://community.esri.com/t5/python-questions/layer-visible/m-p/634758#M49438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see the documentation says that works, but I have had issues in the past.&lt;/P&gt;&lt;P&gt;Would not let me get the dataframe unless I either hard coded the name, or used the "*".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was in earlier version.&amp;nbsp; Maybe I can test again now that I'm running 10.2.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the feedback,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just tested in 10.2.1 and the empty string seems to work fine now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 17:49:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-visible/m-p/634758#M49438</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2017-07-27T17:49:25Z</dc:date>
    </item>
  </channel>
</rss>

