<?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 Re: Modifying MXD layout through python script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270993#M20952</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using ListLayoutElements you can search for a text element that contains a specific phrase (assuming the phrase will always be the same)&amp;nbsp;and then change that text:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; elm &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayoutElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEXT_ELEMENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Text"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new text"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I would insert a map Title in Layout view as it&amp;nbsp;uses dynamic text to access and display&amp;nbsp;the title element&amp;nbsp;from the document's properties.&amp;nbsp; Then use python to edit the title property:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title
&lt;SPAN class="comment token"&gt;# prints map document property title&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# found at File &amp;gt; Map Document Properties&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# set map document title and refresh&lt;/SPAN&gt;
mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"My Big Map"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See: &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/map/page-layouts/working-with-dynamic-text.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Working with dynamic text&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand your second question, something like this will rename a feature layer to a value found in a field in the feature's first row using SearchCursor.&amp;nbsp; Line 1 causes this to loop through all layers, but if you have a specific layer name, you might be able to just use a modification of line 3.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; layer &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# change layer.name to value in found in FieldName of first row of SearchCursor&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FieldName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:14:58 GMT</pubDate>
    <dc:creator>RandyBurton</dc:creator>
    <dc:date>2021-12-11T13:14:58Z</dc:date>
    <item>
      <title>Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270989#M20948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Working on a big geoprocessing tool that generates a pdf map from an mxd using arcpy mapping.&amp;nbsp; For every run of the tool, we need the title to change based on some user inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, we have a feature class that gets truncated/appended during the script run.&amp;nbsp; In the legend, we are displaying a 'Name' attribute for this particular feature class.&amp;nbsp; The FC will always contain only 1 record, but we need the value in the legend to change to reflect the most current value in the FC.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically I have 2 python/ArcMap layout questions - title taking user-input values and refreshing values in the legend (which are based on the symbology and values there).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've looked at dynamic text options, but these don't appear to have access to attribute-level values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Allen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2017 20:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270989#M20948</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-20T20:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270990#M20949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;arcpy.mapping.ListLayoutElements should get you access to the title I'd think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/listlayoutelements.htm"&gt;http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/listlayoutelements.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2017 20:44:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270990#M20949</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2017-10-20T20:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270991#M20950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks James -&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've looked at ListLayoutElements briefly.&amp;nbsp; Experimenting just now, I can't seem to get it to work. I inserted a text element as a title in the layout (keeping 'Text' as the default value), then ran the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for elm in arcpy.mapping.ListLayoutElements(ownerMxd, "TEXT_ELEMENT"):&lt;BR /&gt; if elm.text=="Text":&lt;BR /&gt; elm = permitType&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;permitType is a user-input variable (hard-coded for now while developing).&amp;nbsp; No errors, but the resulting PDF still just shows 'Text' in the title text box.&amp;nbsp; I'm sure I'm missing something obvious here.&amp;nbsp; I am running a 'refresh active view' and 'save' command for the mxd.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2017 21:47:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270991#M20950</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-20T21:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270992#M20951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And I already see my mistake - will keep testing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Oct 2017 21:56:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270992#M20951</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-20T21:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270993#M20952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using ListLayoutElements you can search for a text element that contains a specific phrase (assuming the phrase will always be the same)&amp;nbsp;and then change that text:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; elm &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayoutElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEXT_ELEMENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Text"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new text"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I would insert a map Title in Layout view as it&amp;nbsp;uses dynamic text to access and display&amp;nbsp;the title element&amp;nbsp;from the document's properties.&amp;nbsp; Then use python to edit the title property:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title
&lt;SPAN class="comment token"&gt;# prints map document property title&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# found at File &amp;gt; Map Document Properties&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# set map document title and refresh&lt;/SPAN&gt;
mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"My Big Map"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See: &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/map/page-layouts/working-with-dynamic-text.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Working with dynamic text&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand your second question, something like this will rename a feature layer to a value found in a field in the feature's first row using SearchCursor.&amp;nbsp; Line 1 causes this to loop through all layers, but if you have a specific layer name, you might be able to just use a modification of line 3.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; layer &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# change layer.name to value in found in FieldName of first row of SearchCursor&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FieldName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:14:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270993#M20952</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T13:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270994#M20953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is perfect - thanks Randy.&amp;nbsp; Working well so far.&amp;nbsp; One more scenario I think I understand but want to check on:&lt;/P&gt;&lt;P&gt;We will have 3 text elements at the bottom of the map that need to get updated with each run of the script.&amp;nbsp; Thinking this could be tricky since the value will change.&amp;nbsp; So&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"&gt;if&lt;/SPAN&gt; elm&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;==&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"Text"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;:&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;obviously won't be "Text" after the initial run. I'm thinking with some wise use wildcards and consistency in the values that get written I can work with this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2017 16:37:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270994#M20953</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-23T16:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270995#M20954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some thoughts...&lt;/P&gt;&lt;P&gt;ListLayoutElements may loop through TEXT_ELEMENTs in the same order.&amp;nbsp; If so, you might be able to set values using this order.&amp;nbsp; If you delete and add new elements, this order may change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have your search text set to a certain default value ("Element1", "Element2", etc.).&amp;nbsp; Have your script replace these values, print your PDF and then restore the text back to the default values (assuming you are resaving your map each time).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Text Elements also have other properties, such as position (elementPositionX, elementPositionY), which may help&amp;nbsp;identify&amp;nbsp;the elements.&lt;/P&gt;&lt;P&gt;See: &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/textelement-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;TextElement&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Even better, name your text elements to identify them.&amp;nbsp; On the "Size and Position" property tab for the text element, there is a box for "Element Name", or you can use Python:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;txtCount &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; elm &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayoutElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"TEXT_ELEMENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TextBox_{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txtCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; txtCount &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; elm &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayoutElements&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"TEXT_ELEMENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TextBox_1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"new text"&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:15:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270995#M20954</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T13:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270996#M20955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is perfect - each text value is populated with a variable in the script, so when done with the pdf generation I can still reference the variable and reset the value to the keyword - works like a charm:&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set text value to desired attribute (extracted in variable creation)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for elm in arcpy.mapping.ListLayoutElements(ownerMxd, "TEXT_ELEMENT"):&lt;BR /&gt; if elm.text == "NHA":&lt;BR /&gt; elm.text = siteNHA&amp;nbsp; (this is the formatted + attribute-based variable)&lt;BR /&gt; print elm.text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reset text value to default after pdf generation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for elm in arcpy.mapping.ListLayoutElements(ownerMxd, "TEXT_ELEMENT"):&lt;BR /&gt; if elm.text == siteNHA:&amp;nbsp;&lt;BR /&gt; elm.text = "NHA"&lt;BR /&gt; print elm.text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially just reversing the value in the 'if' and next elm.text = ... lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks, this is super useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270996#M20955</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-23T19:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying MXD layout through python script?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270997#M20956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will add that I missed the last edit you had - I saw that and believe it would be simpler - would remove the additional step of re-setting the text values to their generic keywords.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2017 21:54:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-mxd-layout-through-python-script/m-p/270997#M20956</guid>
      <dc:creator>AllenScully</dc:creator>
      <dc:date>2017-10-23T21:54:53Z</dc:date>
    </item>
  </channel>
</rss>

