<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic arcpy how to set the camera heading and extent in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-how-to-set-the-camera-heading-and-extent/m-p/1563774#M90707</link>
    <description>&lt;P&gt;Using ArcGIS pro 3.3&lt;/P&gt;&lt;P&gt;In a stand-alone python script, copying a aprx and changing the source and some other properties...&amp;nbsp; ArcGIS pro is not running.&amp;nbsp; There are two problems.&amp;nbsp; One if the Mapview extent and rotation (heading) is not updated when I open the project.&amp;nbsp; If I close the map view and re-open the map, the extent is set but not the heading.&amp;nbsp; &amp;nbsp;I would like if when the project is open, the mapview would be centered on the extent and the rotation would be set.&amp;nbsp; The activeMap and activeView are None at run time.&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject(self.templateAPRX) #file name of the default&lt;BR /&gt;aprx.updateConnectionProperties(current_connection_info= self.templateGDB, new_connection_info= self.projectGDB)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I I do this inside ArcGIS pro python window, I get the same problem with the heading if it is applied on the map (closed map) but the set extent works.&amp;nbsp; Heading and extent work on the activeView but these are None for me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I set the map extent and rotation for a project without having it open?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;logging.info("set rotation to {angle}".format(angle=str(self.analysisRotation)))&lt;BR /&gt;listEditMap = aprx.listMaps(self.editorMap)&lt;BR /&gt;if len(listEditMap) != 1:&lt;BR /&gt;raise Exception("There must be exactly one map named {mapname}, {cnt} were found".format(self.editorMap, str(len(listEditMap))))&lt;BR /&gt;editMap = listEditMap[0]&lt;BR /&gt;&lt;BR /&gt;editMap.defaultCamera.heading = self.analysisRotation *-1&lt;BR /&gt;if self.analysisPolygon:&lt;BR /&gt;editMap.defaultCamera.setExtent(self.analysisPolygon.extent)&lt;BR /&gt;&lt;BR /&gt;editMap.openView() #does nothing if the aprx is not current?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;aprx.saveACopy(self.projectAPRX)&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2024 18:08:52 GMT</pubDate>
    <dc:creator>AlexanderGray</dc:creator>
    <dc:date>2024-12-02T18:08:52Z</dc:date>
    <item>
      <title>arcpy how to set the camera heading and extent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-how-to-set-the-camera-heading-and-extent/m-p/1563774#M90707</link>
      <description>&lt;P&gt;Using ArcGIS pro 3.3&lt;/P&gt;&lt;P&gt;In a stand-alone python script, copying a aprx and changing the source and some other properties...&amp;nbsp; ArcGIS pro is not running.&amp;nbsp; There are two problems.&amp;nbsp; One if the Mapview extent and rotation (heading) is not updated when I open the project.&amp;nbsp; If I close the map view and re-open the map, the extent is set but not the heading.&amp;nbsp; &amp;nbsp;I would like if when the project is open, the mapview would be centered on the extent and the rotation would be set.&amp;nbsp; The activeMap and activeView are None at run time.&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject(self.templateAPRX) #file name of the default&lt;BR /&gt;aprx.updateConnectionProperties(current_connection_info= self.templateGDB, new_connection_info= self.projectGDB)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I I do this inside ArcGIS pro python window, I get the same problem with the heading if it is applied on the map (closed map) but the set extent works.&amp;nbsp; Heading and extent work on the activeView but these are None for me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I set the map extent and rotation for a project without having it open?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;logging.info("set rotation to {angle}".format(angle=str(self.analysisRotation)))&lt;BR /&gt;listEditMap = aprx.listMaps(self.editorMap)&lt;BR /&gt;if len(listEditMap) != 1:&lt;BR /&gt;raise Exception("There must be exactly one map named {mapname}, {cnt} were found".format(self.editorMap, str(len(listEditMap))))&lt;BR /&gt;editMap = listEditMap[0]&lt;BR /&gt;&lt;BR /&gt;editMap.defaultCamera.heading = self.analysisRotation *-1&lt;BR /&gt;if self.analysisPolygon:&lt;BR /&gt;editMap.defaultCamera.setExtent(self.analysisPolygon.extent)&lt;BR /&gt;&lt;BR /&gt;editMap.openView() #does nothing if the aprx is not current?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;aprx.saveACopy(self.projectAPRX)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 18:08:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-how-to-set-the-camera-heading-and-extent/m-p/1563774#M90707</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2024-12-02T18:08:52Z</dc:date>
    </item>
  </channel>
</rss>

