<?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: text property of the text element equal to the value from row in attribute field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219462#M16898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are a couple of other things I see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, your lyr variable is not a layer, it is currently a python list.&amp;nbsp; Change:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lyr = arcpy.mapping.ListLayers(mxd, "Routes2010_NHigh_Alldata", df1)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lyr = arcpy.mapping.ListLayers(mxd, "Routes2010_NHigh_Alldata", df1)[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To get better performance, don't call ListLayoutElements so many times.&amp;nbsp; Just call it once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp; if elm.name == "RTNUM": RtNumElem = elm
&amp;nbsp; if elm.name == "COUNTY": CoElem = elm
&amp;nbsp; if elm.name == "LOCATION": LocElem = elm

&amp;nbsp; ...

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:42:39 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2021-12-11T10:42:39Z</dc:date>
    <item>
      <title>text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219460#M16896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In ArcMap 10.0, is it possible to access the attributes from a layer to populate the text property of text elements in the map document. Or do you have to be using data driven pages?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to do just that. A portion of my code worked, but then I started to receive parsing errors including syntax and attribute errors. It might have to do with the whereclause under the SearchCursor. Perhaps I should set up a definition query based on the route number.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# import arcpy
import arcpy

#Get parameter as text
RtNum = arcpy.GetParameterAsText(0)

#set to current map document
mxd = arcpy.mapping.MapDocument("CURRENT")

# set dataframe to current
df1 = arcpy.mapping.ListDataFrames(mxd,"SurveyMap")[0]
df2 = arcpy.mapping.ListDataFrames(mxd,"InsetMap")[0]

#set current layer
lyr = arcpy.mapping.ListLayers(mxd, "Routes2010_NHigh_Alldata", df1)


# get the reference to the text elements in the map document. I have 14 text elements.
RtNumElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "RTNUM")[0]
CoElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "COUNTY")[0]
LocElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "LOCATION")[0]
DateElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "DATE")[0]
TimeStartElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TimeStart")[0]
TimeEndElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TimeStop")[0]
TempStartElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TempStart")[0]
TempEndElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TempStop")[0]
RHStartElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "RelHumStart")[0]
RHEndElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "RelHumstop")[0]
WStartElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "WindStart")[0]
WEndElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "WindStop")[0]
SurvElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Surveyors")[0]
LengthElem = arcpy.mapping.ListLayoutElements (mxd, "TEXT_ELEMENT", "RouteLength")[0]



# create a cursor and or create definition query for SURVEYS All Text Elements
rows = arcpy.SearchCursor("Routes*", "RTNUM = ", "","","","")
row = rows.next()

RtNumElem.text = row.getValue("RTNUM")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
CoElem.text = row.getValue("County")
LocElem.text = row.getValue(???Location???)
DateElem.text = row.getValue(???Start_Date???)
TempStartElem.text = row.getValue(???Start_Temp???)
TempEndElem.text = row.getValue(???End_Temp???)
RHStartElem.text = row.getValue(???Start_Humi")
RHEndElem.text = row.getValue(???End_Humidi???)
WStartElem.text = row.getValue(???Start_Wind???)
WEndElem.text = row.getValue(???End_Wind???)
SurvElem.text = row.getValue(???Surveyor_s???)
LengthElem.text = row.getvalue("Length")

# refresh map
arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very new to python, so any help would be greatly appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 15:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219460#M16896</guid>
      <dc:creator>AnneReis</dc:creator>
      <dc:date>2012-12-10T15:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219461#M16897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are few things to look for:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Make sure you are using only normal quotes. I see some back and forward quotes in your code, which would definitely break things.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. SearchCursor can't use a wild card, it has to specifically name a layer or table view&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. The query expression in your search cursor is not complete, you need the whole expression, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
where = "RTNUM = '{}'".format(RtNum)
rows = arcpy.SearchCursor(lyr, "RTNUM = ", "","","","")
row = rows.next()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219461#M16897</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219462#M16898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are a couple of other things I see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, your lyr variable is not a layer, it is currently a python list.&amp;nbsp; Change:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lyr = arcpy.mapping.ListLayers(mxd, "Routes2010_NHigh_Alldata", df1)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;to&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lyr = arcpy.mapping.ListLayers(mxd, "Routes2010_NHigh_Alldata", df1)[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To get better performance, don't call ListLayoutElements so many times.&amp;nbsp; Just call it once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp; if elm.name == "RTNUM": RtNumElem = elm
&amp;nbsp; if elm.name == "COUNTY": CoElem = elm
&amp;nbsp; if elm.name == "LOCATION": LocElem = elm

&amp;nbsp; ...

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219462#M16898</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T10:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219463#M16899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much Jeff and Curtis for your corrections to my code. I'm still getting syntax errors during the 'set the text property of the text element equal to the value from the fields' portion of the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for row in rows:
RtNumElem.text = row.getValue("RTNUM")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
CoElem.text = row.getValue("County")
LocElem.text = row.getValue(�??Location�?�)
DateElem.text = row.getValue(�??Start_Date�?�)
TimeStartElem.text = row.getValue (�??Start_Time�?�)
TimeStopElem.text = row.getValue (�??End_Time�?�)
TempStartElem.text = row.getValue(�??Start_Temp�?�)
TempStopElem.text = row.getValue(�??End_Temp�?�)
RHStartElem.text = row.getValue(�??Start_Humi")
RHStopElem.text = row.getValue(�??End_Humidi�?�)
WStartElem.text = row.getValue(�??Start_Wind�?�)
WEndElem.text = row.getValue(�??End_Wind�?�)
SurvElem.text = row.getValue(�??Surveyor_s�?�)
LengthElem.text = row.getvalue("Length")&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The first two lines (RTNUM and County) work without error (and the text elements are populated with the field data after RefreshActiveView), but then the syntax errors occur for Lines 3 through 12. Does this have anything to do with the field properties in the layer? Do I need a colon after each getValue line?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219463#M16899</guid>
      <dc:creator>AnneReis</dc:creator>
      <dc:date>2021-12-11T10:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219464#M16900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm still getting syntax errors during the 'set the text property of the text element equal to the value from the fields' portion of the code.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- You need to indent all statements inside the loop (have you run through the Python tutorial at Python.org?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- As I mentioned, avoid the curly quotes, your options are straight single and double quotes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; RtNumElem.text = row.getValue("RTNUM")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; CoElem.text = row.getValue("County")
&amp;nbsp;&amp;nbsp;&amp;nbsp; LocElem.text = row.getValue(&lt;SPAN style="color:red;"&gt;�??&lt;/SPAN&gt;Location&lt;SPAN style="color:red;"&gt;�?�&lt;/SPAN&gt;) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; (...)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219464#M16900</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219465#M16901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wasn't even aware of curly quotes and not sure how I even typed them. Thanks again for pointing that out. Wasn't sure what you meant.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 15:59:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219465#M16901</guid>
      <dc:creator>AnneReis</dc:creator>
      <dc:date>2012-12-12T15:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: text property of the text element equal to the value from row in attribute field</title>
      <link>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219466#M16902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I wasn't even aware of curly quotes and not sure how I even typed them. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Beware the curse of the curly quotes (in Microsoft Word):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.techrepublic.com/blog/msoffice/turn-off-words-smart-quotes/1547"&gt;http://www.techrepublic.com/blog/msoffice/turn-off-words-smart-quotes/1547&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you're not using an IDE (like IDLE or PythonWin) to edit your Python code, I highly recommend it --&amp;nbsp; because of the requirement for fanatically accurate indentation!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 16:08:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-property-of-the-text-element-equal-to-the/m-p/219466#M16902</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-12-12T16:08:13Z</dc:date>
    </item>
  </channel>
</rss>

