<?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 Change layer visibility range with arcpy in ArcPro in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359292#M69375</link>
    <description>&lt;P&gt;I'm trying to change feature layer visibility ranges with Arcpy in ArcPro but am running into issues. For some reason all of the layers don't support scale ranges despite them being feature layers in the TOC. I can change the visibility ranges manually in Pro. The code below runs with no errors, but none of the visibility ranges change.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="code.jpg" style="width: 574px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88665i4964768934BB0A54/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.jpg" alt="code.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is printed after running the code...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="print_message.jpg" style="width: 345px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88666i7FA7DD79FBD354E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="print_message.jpg" alt="print_message.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;What am I doing wrong? How can I make this happen?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 20:52:15 GMT</pubDate>
    <dc:creator>cweirpatrickco</dc:creator>
    <dc:date>2023-12-11T20:52:15Z</dc:date>
    <item>
      <title>Change layer visibility range with arcpy in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359292#M69375</link>
      <description>&lt;P&gt;I'm trying to change feature layer visibility ranges with Arcpy in ArcPro but am running into issues. For some reason all of the layers don't support scale ranges despite them being feature layers in the TOC. I can change the visibility ranges manually in Pro. The code below runs with no errors, but none of the visibility ranges change.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="code.jpg" style="width: 574px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88665i4964768934BB0A54/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.jpg" alt="code.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is printed after running the code...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="print_message.jpg" style="width: 345px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88666i7FA7DD79FBD354E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="print_message.jpg" alt="print_message.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;What am I doing wrong? How can I make this happen?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 20:52:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359292#M69375</guid>
      <dc:creator>cweirpatrickco</dc:creator>
      <dc:date>2023-12-11T20:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility range with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359343#M69376</link>
      <description>&lt;P&gt;have you tried without the try except block?&amp;nbsp; I'm not sure of a layer property VISIBLESCALE so that may be forcing it into the except.&amp;nbsp; Your error message may be misleading by that logic.&lt;/P&gt;&lt;P&gt;Is this ArcMap or Pro? it might be min and maxThreshold properties now.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 20:17:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359343#M69376</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-12-11T20:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility range with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359377#M69378</link>
      <description>&lt;P&gt;Removing lyr.supports("VISIBLESCALE") and switching minScale and maxScale to minThreshold and maxThreshold was the fix! &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm" target="_self"&gt;ESRI Documentation&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the working code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="working_code.jpg" style="width: 553px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/88683iF20EE0629D86A267/image-size/large?v=v2&amp;amp;px=999" role="button" title="working_code.jpg" alt="working_code.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 21:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359377#M69378</guid>
      <dc:creator>cweirpatrickco</dc:creator>
      <dc:date>2023-12-11T21:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility range with arcpy in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359379#M69379</link>
      <description>&lt;P&gt;Screenshots of code are pretty much useless unless the issue is really obvious and the code is short. Please post code as text in future.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;How to insert code in your post&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 21:10:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359379#M69379</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2023-12-11T21:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility range with arcpy in ArcPro</title>
      <link>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359382#M69380</link>
      <description>&lt;P&gt;Yeah, I was originally going to but it started giving me trouble about it being HTML so I resorted to screenshots.&lt;BR /&gt;&lt;BR /&gt;Thanks for the link though.&lt;BR /&gt;&lt;BR /&gt;Here's the working code snippet:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def set_visibility_range(lyr, min_threshold, max_threshold):
    if lyr.isFeatureLayer:
        lyr.visible = True
        lyr.minThreshold = min_threshold
        lyr.maxThreshold = max_threshold
    else:
        print(f"'{lyr.name}' does not support scale ranges")


for lyr in m.listLayers():
    if "Primary" in lyr.name:
        set_visibility_range(lyr, 300000, 0)
    elif "Secondary" in lyr.name:
        set_visibility_range(lyr, 2500, 0)
    elif "Pole" in lyr.name and "Anno" not in lyr.name:
        set_visibility_range(lyr, 5000, 0)
    elif "Anno" in lyr.name:
        set_visibility_range(lyr, 2500, 0)
    else:
        set_visibility_range(lyr, 0, 0)

aprx.save()

print("FC visibility ranges set...")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 11 Dec 2023 21:14:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-layer-visibility-range-with-arcpy-in-arcpro/m-p/1359382#M69380</guid>
      <dc:creator>cweirpatrickco</dc:creator>
      <dc:date>2023-12-11T21:14:26Z</dc:date>
    </item>
  </channel>
</rss>

