Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Setting Field Visibility

$
0
0
Anyone know how to make fields in a Feature Layer visible or hidden?

Tried using the Field Info object, no luck there...
Code:

desc = arcpy.Describe("FeatureLayer")
field_info = desc.fieldInfo
visibleFields = ["ID", "NAME", "Rank", "Count"]
for index in xrange(0, field_info.count):
    fieldName = str(field_info.getfieldname(index))
    if fieldName in visibleFields:
        print "Found Field " + str(fieldName) + " in visibleFields. Setting Visible..."
        field_info.setvisible(index, "VISIBLE")
    else:
        print "Field " + str(fieldName) + " not found in visibleFields. Setting Hidden..."
        field_info.setvisible(index, "HIDDEN")

Tried tossing a RefreshActiveView() onto the end, that didn't help either.

Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images