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('*')
m_cim = m.getDefinition('V2') #Get the Map's CIM definition
extent = m.listLayers('*').getExtent()
CimExtent = arcpy.cim.CreateCIMObjectFromClassName('CIMExtentIndicator', 'V2')
CimExtent .values = extent
m_cim.defaultExtent = RGBColor
Does the CIMExtentIndicator is the good object type to set the extent of the map.
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.
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.