I'm using ArcGIS Pro 3.2 and I'm trying to use arcpy.mp and the layout CIM to update a scale bar's units.
This is what I have so far, but the units somehow get erased from the layout cim json instead of updated:
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
vicinityLayout = aprx.listLayouts("Fig1_Vicinity")[0]
# Update scale bar units to miles
scaleBarName = 'Scale Bar'
vicinityLayoutCIM = vicinityLayout.getDefinition("V3") # Get the layout CIM
## Find the Scale Bar - updating the units for the
jsonText = "{\"uwkid\":9093}"
for elm in vicinityLayoutCIM.elements:
if elm.name == "Scale Bar":
elm.unitLabel = "Miles"
elm.numberFormat.roundingValue = 0
elm.units = jsonText
vicinityLayout.setDefinition(vicinityLayoutCIM)