I am trying to automate configuring popups with Python CIM for many points in ArcGIS Pro. I only want one field displayed, and not all of them, when I click the point with the info button. That's it. I am new to using Python CIM with arcpy.
I tried the following code and it did not work:
import arcpy
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
l = m.listLayers()[0]
l_cim = l.getDefinition('V2')
for l in m.listLayers():
l_cim = l.getDefinition('V2')
MediaObj = arcpy.cim.CreateCIMObjectFromClassName('CIMTableMediaInfo', 'V2')
MediaObj.fields = ["Field"]
l_cim.popupInfo = MediaObj
l.setDefinition(l_cim)
Please let me know where my understanding has failed.
Solved! Go to Solution.
PopupInfo has a list of TableMediaInfo objects.
l_cim = l.getDefinition("V2")
media = arcpy.cim.CIMPopup.CIMTableMediaInfo()
media.fields = ["Field"]
popup = arcpy.cim.CIMPopup.CIMPopupInfo()
popup.mediaInfos = [media]
l_cim.popupInfo = popup
l.setDefinition(l_cim)
PopupInfo has a list of TableMediaInfo objects.
l_cim = l.getDefinition("V2")
media = arcpy.cim.CIMPopup.CIMTableMediaInfo()
media.fields = ["Field"]
popup = arcpy.cim.CIMPopup.CIMPopupInfo()
popup.mediaInfos = [media]
l_cim.popupInfo = popup
l.setDefinition(l_cim)
Thank you, Johannes! The code worked!
How do I get the list of TableMediaInfo objects from PopupInfo?
cim.popupInfo.mediaInfos
I have leveraged some of this code to modify the l_cim.popupInfo.fieldDescriptions. This seems to be corrupting my map document. Has this ben observed in similar efforts?