Hi,
I am trying to use python to turn fields on and off for layers in my table of contents using the 'fieldInfo.setVisible' method. I can get it to run through and then output as setVisible = "NOT VISIBLE" but the fields remains visible and under the layer properties -> field tab the box is still checked next to the indicated field. Is this a bug or am I not using this method properly?
Code below:
Thank you,
Nathan
I am trying to use python to turn fields on and off for layers in my table of contents using the 'fieldInfo.setVisible' method. I can get it to run through and then output as setVisible = "NOT VISIBLE" but the fields remains visible and under the layer properties -> field tab the box is still checked next to the indicated field. Is this a bug or am I not using this method properly?
Code below:
Code:
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
### set layer
lyr = "StructurePnt"
fieldList = arcpy.ListFields(lyr)
desc = arcpy.Describe(lyr)
fieldInfo = desc.fieldInfo
### field index number
fldIndxNum = 6
fieldInfo.setVisible( fldIndxNum, 'NOT VISIBLE' )
print "\tField Name: " + fieldInfo.getFieldName(fldIndxNum)
print "\tVisible: " + fieldInfo.getVisible(fldIndxNum)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
Nathan