<?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 ArcPy to set visibility range not working in ArcPro 2.8.8 in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-to-set-visibility-range-not-working-in/m-p/1517294#M86676</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Hi fellow ESRI users - I'd be very grateful to get some guidance to get around my wall! If someone has a basic working script it would be appreciated!&lt;/P&gt;&lt;P&gt;I need to automate the configuration of properties for a large number of Feature Layers that are based on queries of a base Filegeodatabase in ArcPro version 2.8.8. The first part of the process has gone smoothly where I add a series of feature layers using -&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;arcpy.management.MakeFeatureLayer. The layers are named and limited based on a query which is working really well.&lt;/P&gt;&lt;P&gt;For each layer I need to set appropriate display scale so can do this manually in - Properties\General\In beyond (maximum scale) and Out beyond (minimum scale)&lt;/P&gt;&lt;P&gt;To set this programmatically it looks like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;layer name&amp;gt;.minScale&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;layer name&amp;gt;.maxScale&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should work with scale as integers.&lt;/P&gt;&lt;P&gt;The following code show how this is not working - note the test geodatabase is constructed in path is c:\tmp\&lt;/P&gt;&lt;PRE&gt;import arcpy
import os

# Define paths and names
workspace = r"C:\tmp\ExampleGeodatabase2.gdb"
feature_class_name = "ExampleFeatureClass"

# Create a new file geodatabase
if not arcpy.Exists(workspace):
    arcpy.CreateFileGDB_management(os.path.dirname(workspace), os.path.basename(workspace))

# Set the workspace environment
arcpy.env.workspace = workspace

# Define the path for the new feature class
feature_class_path = os.path.join(workspace, feature_class_name)

# Create a simple feature class with a point geometry
if not arcpy.Exists(feature_class_path):
    arcpy.CreateFeatureclass_management(workspace, feature_class_name, "POINT", spatial_reference=arcpy.SpatialReference(4326))

# Add a field to the feature class
arcpy.AddField_management(feature_class_path, "Name", "TEXT")

# Create a new ArcGIS Pro project and map
aprx = arcpy.mp.ArcGISProject("CURRENT")
map_obj = aprx.listMaps()[0]

# Add the feature class to the map
layer = map_obj.addDataFromPath(feature_class_path)

# Set the desired scale range
min_scale = 100000  # Maximum scale (1:100,000)
max_scale = 1000    # Minimum scale (1:1,000)

# Set the scale range for visibility if the layer is a FeatureLayer
if layer.isFeatureLayer:
    layer.minScale = min_scale
    layer.maxScale = max_scale
    print(f"Set scale range for '{layer.name}' to minScale: {min_scale}, maxScale: {max_scale}")
else:
    print(f"'{layer.name}' is not a FeatureLayer and cannot have scale ranges set.")

# Save changes to the project
aprx.save()

print("Feature class created, added to the map, and scale range set.")

&lt;/PRE&gt;&lt;P&gt;If this was working, Properties/General should show the scale range set however I only see&lt;/P&gt;&lt;P&gt;I've tried the range as decimals so 0.0001 and text in the form 1:100 and so far the visibility is not being set.&lt;/P&gt;&lt;P&gt;I've resorted to using GPT to write versions however so far it always completes with no errors however also does not set the scale interval.&lt;/P&gt;&lt;P&gt;Any help would be most appreciated as I have not been able to find anything via search and 4 hours of testing different approaches is leaving me with no result.&lt;/P&gt;&lt;P&gt;Thanks Bevan&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 09 Aug 2024 07:25:00 GMT</pubDate>
    <dc:creator>BevanWard</dc:creator>
    <dc:date>2024-08-09T07:25:00Z</dc:date>
    <item>
      <title>ArcPy to set visibility range not working in ArcPro 2.8.8</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-to-set-visibility-range-not-working-in/m-p/1517294#M86676</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Hi fellow ESRI users - I'd be very grateful to get some guidance to get around my wall! If someone has a basic working script it would be appreciated!&lt;/P&gt;&lt;P&gt;I need to automate the configuration of properties for a large number of Feature Layers that are based on queries of a base Filegeodatabase in ArcPro version 2.8.8. The first part of the process has gone smoothly where I add a series of feature layers using -&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;arcpy.management.MakeFeatureLayer. The layers are named and limited based on a query which is working really well.&lt;/P&gt;&lt;P&gt;For each layer I need to set appropriate display scale so can do this manually in - Properties\General\In beyond (maximum scale) and Out beyond (minimum scale)&lt;/P&gt;&lt;P&gt;To set this programmatically it looks like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;layer name&amp;gt;.minScale&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;layer name&amp;gt;.maxScale&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should work with scale as integers.&lt;/P&gt;&lt;P&gt;The following code show how this is not working - note the test geodatabase is constructed in path is c:\tmp\&lt;/P&gt;&lt;PRE&gt;import arcpy
import os

# Define paths and names
workspace = r"C:\tmp\ExampleGeodatabase2.gdb"
feature_class_name = "ExampleFeatureClass"

# Create a new file geodatabase
if not arcpy.Exists(workspace):
    arcpy.CreateFileGDB_management(os.path.dirname(workspace), os.path.basename(workspace))

# Set the workspace environment
arcpy.env.workspace = workspace

# Define the path for the new feature class
feature_class_path = os.path.join(workspace, feature_class_name)

# Create a simple feature class with a point geometry
if not arcpy.Exists(feature_class_path):
    arcpy.CreateFeatureclass_management(workspace, feature_class_name, "POINT", spatial_reference=arcpy.SpatialReference(4326))

# Add a field to the feature class
arcpy.AddField_management(feature_class_path, "Name", "TEXT")

# Create a new ArcGIS Pro project and map
aprx = arcpy.mp.ArcGISProject("CURRENT")
map_obj = aprx.listMaps()[0]

# Add the feature class to the map
layer = map_obj.addDataFromPath(feature_class_path)

# Set the desired scale range
min_scale = 100000  # Maximum scale (1:100,000)
max_scale = 1000    # Minimum scale (1:1,000)

# Set the scale range for visibility if the layer is a FeatureLayer
if layer.isFeatureLayer:
    layer.minScale = min_scale
    layer.maxScale = max_scale
    print(f"Set scale range for '{layer.name}' to minScale: {min_scale}, maxScale: {max_scale}")
else:
    print(f"'{layer.name}' is not a FeatureLayer and cannot have scale ranges set.")

# Save changes to the project
aprx.save()

print("Feature class created, added to the map, and scale range set.")

&lt;/PRE&gt;&lt;P&gt;If this was working, Properties/General should show the scale range set however I only see&lt;/P&gt;&lt;P&gt;I've tried the range as decimals so 0.0001 and text in the form 1:100 and so far the visibility is not being set.&lt;/P&gt;&lt;P&gt;I've resorted to using GPT to write versions however so far it always completes with no errors however also does not set the scale interval.&lt;/P&gt;&lt;P&gt;Any help would be most appreciated as I have not been able to find anything via search and 4 hours of testing different approaches is leaving me with no result.&lt;/P&gt;&lt;P&gt;Thanks Bevan&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 09 Aug 2024 07:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-to-set-visibility-range-not-working-in/m-p/1517294#M86676</guid>
      <dc:creator>BevanWard</dc:creator>
      <dc:date>2024-08-09T07:25:00Z</dc:date>
    </item>
  </channel>
</rss>

