AnsweredAssumed Answered

Editing layer field properties

Question asked by dmorosiesriitalia-it-esridist Employee on Dec 30, 2015
Latest reply on Feb 12, 2017 by dogdaynoon

Hi all,


I would modify the properties of all layers in an mxd setting, for instance, all the fields as non editable.

The following script seems to work:


import arcpy   


mxd = arcpy.mapping.MapDocument('path-to-mxd')

df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]

layers = arcpy.mapping.ListLayers(mxd,"*",df)


for lyr in layers:

    print "Working on layer: " +

    fields = arcpy.ListFields(lyr.dataSource)

    for f in fields:

        f.editable = False


It runs without errors, prints all the layer names but when I open the mxd nothing has changed, the fields are still editable. By the way the mxd IS saved, I just see a new timestamp in the "last modified" property of the file.

Am I missing something?


Thank you,