When going into Attributes Tables>Fields, the Number format can be edited (Numeric, Percentage, Currency, Rate, ...). Each chosen type has plenty of useful options (number of decimal values, show thousands separators, etc...).
In most cases, once a specific setting has been defined, it would apply to many fields.
It would be great to be able to copy a given Number format and be able to apply it to multiple fields afterwards.
Yes Please!! Also could we also have a corresponding Arcpy command to do this in a script!
I have successfully managed to edit the numberFormats using Python CIM access so it should be possible to do this in a Python Toolbox with the Layer Name and the Field Name as inputs:
e.g:
-----------------------------------------------------------------------------
currentProject = arcpy.mp.ArcGISProject("CURRENT")
currentMap = currentProject.listMaps()[0] #I think this assumes there is only one map
layers = currentMap.listLayers()
for layer in layers:
lyrCIM = layer.getDefinition('V2')
if layer.name == INPUT_LYR:
lyrCIM.showPopups = True
# Modify the display of numeric fields
for fd in lyrCIM.featureTable.fieldDescriptions:
if fd.fieldName == INPUT_FIELD:
fdNumFmt = fd.numberFormat
fdNumFmt.useSeparator = True #Use a comma as a thousands separator
layer.setDefinition(lyrCIM)
currentProject.save
---------------------------------------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.