Hi,
I'm trying to take a table of polygons that split my physical area of interest into 700 chunks. I'm tasked with taking each section and putting it into a layout for making backup paper maps. The layout is no problem, it's the automating of showing the selected section in the map frame that is not working for some reason. I'm new to ArcPy but my research so far seems to point to arcp.da.SearchCursor as the class to carry this out. Like so:
<SPAN class="keyword token">import</SPAN> arcpy
aprx <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CURRENT"</SPAN><SPAN class="punctuation token">)</SPAN>
m <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Maps*"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
lyt <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>listLayouts<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Layout*"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
lyr <SPAN class="operator token">=</SPAN> m<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Layer*"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
mf <SPAN class="operator token">=</SPAN> lyt<SPAN class="punctuation token">.</SPAN>listElements<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"mapframe_element"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MapFrame*"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
fc <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Sections"</SPAN>
field <SPAN class="operator token">=</SPAN> <SPAN class="string token">"OBJECTID"</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
mf<SPAN class="punctuation token">.</SPAN>camera<SPAN class="punctuation token">.</SPAN>setExtent<SPAN class="punctuation token">(</SPAN>mf<SPAN class="punctuation token">.</SPAN>getLayerExtent<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="operator token">/</SPAN>row?<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># and then here I would save to PDF</SPAN>
<SPAN class="keyword token">del</SPAN> row<SPAN class="punctuation token">,</SPAN> cursor<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Judging by my code so far, I think I'm trying to zoom into the wrong thing and that something else is missing. I'm using ArcGIS Pro 2.4.0. Appreciate any assistance, thanks!