jonbruce

Changes to "Visibility" using FieldInfo method not working?

Discussion created by jonbruce on Nov 20, 2012
Hello all,
In the code below, I can get the python window in arcmap to show that the visibility flag is being changed for the apprpriate fields, but the changes aren't being reflected in the new feature layer's attribute table. I've tried updating the MXD, the active view, all sorts of things. Any help would be appreciated.

try:
    layer = pythonaddins.GetSelectedTOCLayerOrDataFrame()            
    fldInfo = arcpy.FieldInfo()
    KeepList = ['Loc_name','Match_type','Match_addr']
    for field in arcpy.ListFields(layer):
        if field.name in list(KeepList):
            fldInfo.addField(field,field ,"VISIBLE","")
    for field in arcpy.ListFields(layer):
            if field.name not in list(KeepList):
                fldInfo.addField(field,field,"HIDDEN","")
except:
    Problem()
else:
    arcpy.MakeFeatureLayer_management(layer, "Formatted","","",fldInfo)

Outcomes