Configuring Popups with Python CIM

921
4
Jump to solution
01-30-2023 09:09 AM
DestinyKelley1
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

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)

Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

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)

Have a great day!
Johannes
DestinyKelley1
New Contributor III

Thank you, Johannes! The code worked!

How do I get the list of TableMediaInfo objects from PopupInfo?

0 Kudos
JohannesLindner
MVP Frequent Contributor
cim.popupInfo.mediaInfos

Have a great day!
Johannes
0 Kudos
John_Medema
Esri Contributor

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?

0 Kudos