Hi ArcGIS Community,
I have a Python script that simply add points to a feature class in file GDB every second. The corresponding layer is in an ArcGIS Pro map, and I would like to visualise the point as their are being added, without manually interacting with the map.
When running the script as a standalone script, panning or zooming will force the map to refresh and display points newly added.
How can I programatically refresh the map to see the update displayed dynamically, without the need for user interaction ?
Thanks
- Windows 8.1
- ArcGIS Pro 1.4.1
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> time<SPAN class="punctuation token">,</SPAN> random<SPAN class="punctuation token">,</SPAN> datetime
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">'D:\workspaces\sandbox\sandbox\sandbox.aprx'</SPAN><SPAN class="punctuation token">)</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SHAPE@XY'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'DATETIME'</SPAN><SPAN class="punctuation token">]</SPAN>
iteration <SPAN class="operator token">=</SPAN> <SPAN class="number token">10</SPAN>
second <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN>
<SPAN class="comment token"># bouding box: east, west, south, north (define your own extent)</SPAN>
boundingBox <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>x1<SPAN class="punctuation token">,</SPAN>x2<SPAN class="punctuation token">,</SPAN>y1<SPAN class="punctuation token">,</SPAN>y2<SPAN class="punctuation token">]</SPAN>
fc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"D:\workspace\mygdb.gdb\Points"</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>iteration<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
x <SPAN class="operator token">=</SPAN> random<SPAN class="punctuation token">.</SPAN>uniform<SPAN class="punctuation token">(</SPAN>boundingBox<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>boundingBox<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
y <SPAN class="operator token">=</SPAN> random<SPAN class="punctuation token">.</SPAN>uniform<SPAN class="punctuation token">(</SPAN>boundingBox<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>boundingBox<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
xy <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">,</SPAN>y<SPAN class="punctuation token">)</SPAN>
cursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> fields<SPAN class="punctuation token">)</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>xy<SPAN class="punctuation token">,</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> cursor
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Done! ... i='</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN>second<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'QUIT'</SPAN><SPAN class="punctuation token">)</SPAN><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></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>