<?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 apply attribute table settings (fields visibility and format) from one layer to another using arcpy? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648914#M74687</link>
    <description>&lt;P&gt;I'd just use the CIM definition object, since all these properties can be set directly using dictionaries/CIM objects:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from typing import Any

from arcpy.management import MakeFeatureLayer
from arcpy.cim.CIMVectorLayers import CIMFeatureLayer
from arcpy.mp import ArcGISProject
from arcpy._mp import Layer, Map

def get_state(lyr: Layer) -&amp;gt; dict[str, Any]:
    layer_cim: CIMFeatureLayer = lyr.getDefinition('V3')
    states_to_save = [
        'snappable', 
        'selectable', 
        'visibility',
        'expanded',
        'labelVisibility',
    ]
    return {k:v for k, v in layer_cim.__dict__ if k in states_to_save}

def apply_state(lyr: Layer, state: dict[str, Any]) -&amp;gt; None:
    if not lyr.isFeatureLayer:
        return
    layer_cim: CIMFeatureLayer = lyr.getDefinition('V3')
    layer_cim.__dict__.update(state)
    lyr.setDefinition(layer_cim)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first function will pull states from a layer and the second will apply those states to a layer. In your case, you can put these in a loop for the map:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...

def update_map_layers(mp: Map, state: dict[str, Any]) -&amp;gt; None:
    for layer in filter(lambda m: m.isFeatureLayer, mp.listLayers()):
        apply_state(layer, state)
        
def main():
    template_layer = MakeFeatureLayer(r'&amp;lt;path/to/template&amp;gt;.lyrx')[0]
    state = get_state(template_layer)
    project = ArcGISProject('&amp;lt;path/to/project&amp;gt;.aprx || CURRENT')
    mp = project.listMaps('&amp;lt;map_name&amp;gt;')[0]
    update_map_layers(mp, state)

if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 09 Sep 2025 13:23:41 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2025-09-09T13:23:41Z</dc:date>
    <item>
      <title>How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648495#M74682</link>
      <description>&lt;P&gt;I have 40 layers with the same table schema and I need to apply symbology and table settings from another layer. I have a template layer and applying symbology works as expected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to apply fields visibility and formats as well?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can see &lt;FONT face="courier new,courier" size="2"&gt;pasteProperties (source_layer, {layer_paste_properties})&lt;/FONT&gt; method but when applying in on a layer object I get the following error: &lt;FONT face="courier new,courier" size="2"&gt;AttributeError: 'Layer' object has no attribute 'pasteProperties'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;L = map.addDataFromPath(r"..\Address.lyrx")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;for lyr in map.listLayers():&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&amp;nbsp; &amp;nbsp; print(lyr.name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&amp;nbsp; &amp;nbsp; lyr.pasteProperties(L, layer_paste_properties="FIELD_PROPERTIES")&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 10:29:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648495#M74682</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-09-08T10:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648516#M74683</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm" target="_blank"&gt;Layer—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you should check if it is a featurelayer before trying to try to pastProperties&lt;/P&gt;&lt;P&gt;isFeatureLayer&lt;BR /&gt;(Read Only)&lt;BR /&gt;Returns True if a layer is a feature layer.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 12:26:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648516#M74683</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-09-08T12:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648603#M74684</link>
      <description>&lt;P&gt;Try this,&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

# Load the template layer
template_layer_path = r"..\Address.lyrx"
template_layer = arcpy.mp.LayerFile(template_layer_path).listLayers()[0]

# Get your map
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps("Your Map Name")[0]

# Apply symbology + field properties
for lyr in map.listLayers():
    if lyr.isFeatureLayer:
        print(f"Updating {lyr.name}...")
        arcpy.management.UpdateLayer(lyr, template_layer, True)  # True = keep data source
        print(f"Completed: {lyr.name}")

print("All layers updated successfully!")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Sep 2025 15:27:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648603#M74684</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-09-08T15:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648869#M74685</link>
      <description>&lt;P&gt;Didn't work..&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;AttributeError: module 'arcpy.management' has no attribute 'UpdateLayer'&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 11:34:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648869#M74685</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-09-09T11:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648914#M74687</link>
      <description>&lt;P&gt;I'd just use the CIM definition object, since all these properties can be set directly using dictionaries/CIM objects:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from typing import Any

from arcpy.management import MakeFeatureLayer
from arcpy.cim.CIMVectorLayers import CIMFeatureLayer
from arcpy.mp import ArcGISProject
from arcpy._mp import Layer, Map

def get_state(lyr: Layer) -&amp;gt; dict[str, Any]:
    layer_cim: CIMFeatureLayer = lyr.getDefinition('V3')
    states_to_save = [
        'snappable', 
        'selectable', 
        'visibility',
        'expanded',
        'labelVisibility',
    ]
    return {k:v for k, v in layer_cim.__dict__ if k in states_to_save}

def apply_state(lyr: Layer, state: dict[str, Any]) -&amp;gt; None:
    if not lyr.isFeatureLayer:
        return
    layer_cim: CIMFeatureLayer = lyr.getDefinition('V3')
    layer_cim.__dict__.update(state)
    lyr.setDefinition(layer_cim)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first function will pull states from a layer and the second will apply those states to a layer. In your case, you can put these in a loop for the map:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...

def update_map_layers(mp: Map, state: dict[str, Any]) -&amp;gt; None:
    for layer in filter(lambda m: m.isFeatureLayer, mp.listLayers()):
        apply_state(layer, state)
        
def main():
    template_layer = MakeFeatureLayer(r'&amp;lt;path/to/template&amp;gt;.lyrx')[0]
    state = get_state(template_layer)
    project = ArcGISProject('&amp;lt;path/to/project&amp;gt;.aprx || CURRENT')
    mp = project.listMaps('&amp;lt;map_name&amp;gt;')[0]
    update_map_layers(mp, state)

if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Sep 2025 13:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648914#M74687</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-09-09T13:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply attribute table settings (fields visibility and format) from one layer to another using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648938#M74688</link>
      <description>&lt;P&gt;try&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;# Use ApplySymbologyFromLayer &lt;/SPAN&gt;
        arcpy&lt;SPAN class=""&gt;.&lt;/SPAN&gt;ApplySymbologyFromLayer_management&lt;SPAN class=""&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class=""&gt;,&lt;/SPAN&gt; template_layer&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Sep 2025 14:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-apply-attribute-table-settings-fields/m-p/1648938#M74688</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-09-09T14:34:21Z</dc:date>
    </item>
  </channel>
</rss>

