<?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 How to get unplaced labels set to &amp;quot;Never Remove&amp;quot; in Python for ArcGIS Pro? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601614#M73981</link>
    <description>&lt;P&gt;I'm writing an automation script that forces some layers to set the unplaced labels to "Never Remove (place overlapping)" as seen in the label class dialog.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DN_GIS_Analyst_0-1743548299675.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/129247i96F6DEBCE84CBD29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DN_GIS_Analyst_0-1743548299675.png" alt="DN_GIS_Analyst_0-1743548299675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I want to do this in python as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")

for m in aprx.listMaps():
    if m.name == "Overview Map":
        print(f"Processing {m.name}:")
        
        for layer in m.listLayers():
            if layer.name == "Pipes by Pressure Zones":
                print(f" - Processing {layer.name}:")
                try:
                    cim_lyr = layer.getDefinition("V3")
                    cim_lyr.labelVisibility = False
                    layer.setDefinition(cim_lyr)
                    print(f" -- Labels turned off for {layer.name} via CIM.")
                except Exception as e:
                    print(f" -- Failed to modify CIM for {layer.name}: {e}")

            if layer.name == "MapBook Pages":
                print(f" - Processing {layer.name}:")
                layer.visible = False
                print(f" -- Turned off {layer.name}")

            if layer.name in ["MapBook Page Sections", "Hydrants"]:
                print(f" - Processing {layer.name}:")
                try:
                    fillRGBColor = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
                    fillRGBColor.values = [255, 255, 255, 100]  # White

                    solFill = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidFill', 'V3')
                    solFill.color = fillRGBColor
                    solFill.enable = True
                    solFill.colorlocked = False
                    solFill.overprint = False

                    sym = arcpy.cim.CreateCIMObjectFromClassName('CIMPolygonSymbol', 'V3')
                    sym.symbolLayers = [solFill]

                    cim_lyr = layer.getDefinition("V3")
                    lc = cim_lyr.labelClasses[0]
                    if layer.name == "MapBook Page Sections":
                        lc.canRemoveOverlappingLabel = False
                        lc.allowOverlappingLabels = True
                        lc.unplacedLabelStrategy = "ForcePlace"
                        
                    lc.visible = True
                    lc.textSymbol.symbol.haloSize = 2
                    lc.textSymbol.symbol.haloSymbol = sym

                    cim_lyr.labelVisibility = True
                    layer.showLabels = True
                    layer.setDefinition(cim_lyr)

                    print(f" -- Labels turned on and halo enabled for {layer.name} via CIM.")
                except Exception as e:
                    print(f" -- Failed to modify CIM for {layer.name}: {e}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm unable to get the unplaced labels to be set to "Never Remove (place overlapping)" or something similar to that. The checkbox was not checked.&lt;/P&gt;&lt;P&gt;My goal is to get this ironed and modified to work on all Pro projects within a folder, so that I don't have to do this manually for each Pro project. Don't worry, I already got code worked out for this last part.&lt;/P&gt;&lt;P&gt;Thanks for whatever help you can give out.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2025 23:03:31 GMT</pubDate>
    <dc:creator>DN_GIS_Analyst</dc:creator>
    <dc:date>2025-04-01T23:03:31Z</dc:date>
    <item>
      <title>How to get unplaced labels set to "Never Remove" in Python for ArcGIS Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601614#M73981</link>
      <description>&lt;P&gt;I'm writing an automation script that forces some layers to set the unplaced labels to "Never Remove (place overlapping)" as seen in the label class dialog.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DN_GIS_Analyst_0-1743548299675.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/129247i96F6DEBCE84CBD29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DN_GIS_Analyst_0-1743548299675.png" alt="DN_GIS_Analyst_0-1743548299675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I want to do this in python as well.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")

for m in aprx.listMaps():
    if m.name == "Overview Map":
        print(f"Processing {m.name}:")
        
        for layer in m.listLayers():
            if layer.name == "Pipes by Pressure Zones":
                print(f" - Processing {layer.name}:")
                try:
                    cim_lyr = layer.getDefinition("V3")
                    cim_lyr.labelVisibility = False
                    layer.setDefinition(cim_lyr)
                    print(f" -- Labels turned off for {layer.name} via CIM.")
                except Exception as e:
                    print(f" -- Failed to modify CIM for {layer.name}: {e}")

            if layer.name == "MapBook Pages":
                print(f" - Processing {layer.name}:")
                layer.visible = False
                print(f" -- Turned off {layer.name}")

            if layer.name in ["MapBook Page Sections", "Hydrants"]:
                print(f" - Processing {layer.name}:")
                try:
                    fillRGBColor = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
                    fillRGBColor.values = [255, 255, 255, 100]  # White

                    solFill = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidFill', 'V3')
                    solFill.color = fillRGBColor
                    solFill.enable = True
                    solFill.colorlocked = False
                    solFill.overprint = False

                    sym = arcpy.cim.CreateCIMObjectFromClassName('CIMPolygonSymbol', 'V3')
                    sym.symbolLayers = [solFill]

                    cim_lyr = layer.getDefinition("V3")
                    lc = cim_lyr.labelClasses[0]
                    if layer.name == "MapBook Page Sections":
                        lc.canRemoveOverlappingLabel = False
                        lc.allowOverlappingLabels = True
                        lc.unplacedLabelStrategy = "ForcePlace"
                        
                    lc.visible = True
                    lc.textSymbol.symbol.haloSize = 2
                    lc.textSymbol.symbol.haloSymbol = sym

                    cim_lyr.labelVisibility = True
                    layer.showLabels = True
                    layer.setDefinition(cim_lyr)

                    print(f" -- Labels turned on and halo enabled for {layer.name} via CIM.")
                except Exception as e:
                    print(f" -- Failed to modify CIM for {layer.name}: {e}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm unable to get the unplaced labels to be set to "Never Remove (place overlapping)" or something similar to that. The checkbox was not checked.&lt;/P&gt;&lt;P&gt;My goal is to get this ironed and modified to work on all Pro projects within a folder, so that I don't have to do this manually for each Pro project. Don't worry, I already got code worked out for this last part.&lt;/P&gt;&lt;P&gt;Thanks for whatever help you can give out.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 23:03:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601614#M73981</guid>
      <dc:creator>DN_GIS_Analyst</dc:creator>
      <dc:date>2025-04-01T23:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unplaced labels set to "Never Remove" in Python for ArcGIS Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601724#M73982</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/780461"&gt;@DN_GIS_Analyst&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lc = cim_lyr.labelClasses[0]
lc.maplexLabelPlacementProperties.neverRemoveLabel = True # or False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know if that works for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 08:38:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601724#M73982</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-04-02T08:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unplaced labels set to "Never Remove" in Python for ArcGIS Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601835#M73983</link>
      <description>&lt;P&gt;Thanks! That worked like a charm.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 14:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-unplaced-labels-set-to-quot-never/m-p/1601835#M73983</guid>
      <dc:creator>DN_GIS_Analyst</dc:creator>
      <dc:date>2025-04-02T14:17:52Z</dc:date>
    </item>
  </channel>
</rss>

