Hello,
I try to set the extent of a map in a aprx by setting the definition of this one. I want to set by setting the defautExtent parameter with a CIM object. Here is my code I want to proceed but it is unsucessful :
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('*')[0]
m_cim = m.getDefinition('V2') #Get the Map's CIM definition
extent = m.listLayers('*')[0].getExtent()
CimExtent = arcpy.cim.CreateCIMObjectFromClassName('CIMExtentIndicator', 'V2')
CimExtent .values = extent
m_cim.defaultExtent = RGBColor
m.setDefinition(m_cim)
p.save()
Does the CIMExtentIndicator is the good object type to set the extent of the map.
Thank you
apparently from the "camera"
Solved: ArcGIS Pro: Set a Map's extent from a layer's exte... - Esri Community
Thank you, but I want to apply the set extent on the map view directly. I am able to do it with the 'activeView' when I got the aprx open, but is it possible without using the activeView. So that's why I wanted to pass by the setDefinition of the map object. I don't have layout in my aprx.
Thank you
I don't see anything in either the mapview of map or CIM function documentation, but I assume you have checked those as well
Hi XavierRouxRacine1,
Have you figured this out? I have the same question as you.
Thanks,
Zhongyu
I discussed it with esri support lately.
The setExtent works on MapView only so there is no way to do it on an aprx that is not current.
Using the CIM to do it can be a workaround if somebody can find the correct way to do it.