<?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 Triggering/Listening python in ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/triggering-listening-python-in-arcmap/m-p/475215#M37230</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First time poster, trying to make python do my bidding, most grateful for any assistance. EPSG:27700&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;# oldDFextent = df.extent&lt;BR /&gt;# while not df.extent = oldDFextent&lt;BR /&gt;elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "GridRefField")[0]&lt;BR /&gt;elm.text = 'SK' + str(((df.extent.XMax - df.extent.XMin) / 2) + df.extent.XMin)[1:3] + str(((df.extent.YMax - df.extent.YMin) / 2) + df.extent.YMin)[1:3]&lt;BR /&gt;arcpy.RefreshActiveView()&lt;BR /&gt;del mxd&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i am trying to achieve is a text element on the layout screen which dynamically updates with the dataframe centroid.&lt;/P&gt;&lt;P&gt;However the built-in dynamic text...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;lt;dyn type="dataFrame" name="Layers" property="center" decimalPlaces="0"/&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...doesn't allow me to manipulate the string it returns at all. I am seeking to coerce it into Ordnance Survey map sheet format...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;i.e. 4&lt;STRONG&gt;62&lt;/STRONG&gt;,697.834 3&lt;STRONG&gt;90&lt;/STRONG&gt;,802.021 becomes SK&lt;STRONG&gt;6290&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, i turn to python. I now have a layout view text element called 'GridRefField', which i am pushing the values i want into using arcpy.mapping. This is working perfectly, but i am having to run the code manually whenever the dataframe extent changes, whereas i want this to just sit in the background and rerun every time the dataframe extent changes &lt;EM&gt;a la&lt;/EM&gt; dynamic text.&lt;/P&gt;&lt;P&gt;How would i go about doing this? Is it doable within python or do i need to move towards coding an AddIn?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for any assistance&lt;/P&gt;&lt;P&gt;Charles&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Aug 2016 12:10:14 GMT</pubDate>
    <dc:creator>CharlesLaughton</dc:creator>
    <dc:date>2016-08-23T12:10:14Z</dc:date>
    <item>
      <title>Triggering/Listening python in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/triggering-listening-python-in-arcmap/m-p/475215#M37230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First time poster, trying to make python do my bidding, most grateful for any assistance. EPSG:27700&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;# oldDFextent = df.extent&lt;BR /&gt;# while not df.extent = oldDFextent&lt;BR /&gt;elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "GridRefField")[0]&lt;BR /&gt;elm.text = 'SK' + str(((df.extent.XMax - df.extent.XMin) / 2) + df.extent.XMin)[1:3] + str(((df.extent.YMax - df.extent.YMin) / 2) + df.extent.YMin)[1:3]&lt;BR /&gt;arcpy.RefreshActiveView()&lt;BR /&gt;del mxd&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i am trying to achieve is a text element on the layout screen which dynamically updates with the dataframe centroid.&lt;/P&gt;&lt;P&gt;However the built-in dynamic text...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;lt;dyn type="dataFrame" name="Layers" property="center" decimalPlaces="0"/&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...doesn't allow me to manipulate the string it returns at all. I am seeking to coerce it into Ordnance Survey map sheet format...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;i.e. 4&lt;STRONG&gt;62&lt;/STRONG&gt;,697.834 3&lt;STRONG&gt;90&lt;/STRONG&gt;,802.021 becomes SK&lt;STRONG&gt;6290&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So, i turn to python. I now have a layout view text element called 'GridRefField', which i am pushing the values i want into using arcpy.mapping. This is working perfectly, but i am having to run the code manually whenever the dataframe extent changes, whereas i want this to just sit in the background and rerun every time the dataframe extent changes &lt;EM&gt;a la&lt;/EM&gt; dynamic text.&lt;/P&gt;&lt;P&gt;How would i go about doing this? Is it doable within python or do i need to move towards coding an AddIn?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for any assistance&lt;/P&gt;&lt;P&gt;Charles&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2016 12:10:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/triggering-listening-python-in-arcmap/m-p/475215#M37230</guid>
      <dc:creator>CharlesLaughton</dc:creator>
      <dc:date>2016-08-23T12:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Triggering/Listening python in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/triggering-listening-python-in-arcmap/m-p/475216#M37231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcPy doesn't deal with events, at least listening for them, i.e., there is no "triggering/listening"&amp;nbsp;built natively into the site package.&amp;nbsp; If you want to access ArcObjects events from Python, you can use comtypes or some other Python-based COM interface package.&amp;nbsp; Even going down that road, I am not sure how, or if, one would get it to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2016 12:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/triggering-listening-python-in-arcmap/m-p/475216#M37231</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-23T12:40:16Z</dc:date>
    </item>
  </channel>
</rss>

