<?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: Refresh Layer After Adding Field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489175#M38268</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you post your tools parameters values for this tool please?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Aug 2012 20:46:47 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2012-08-08T20:46:47Z</dc:date>
    <item>
      <title>Refresh Layer After Adding Field</title>
      <link>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489173#M38266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have created a python script that adds and updates a field within an existing feature class added to ArcMap.&amp;nbsp; I have set the script to run as a tool in the map document.&amp;nbsp; The script executes fine adding/udating the field 'Acres' to the polygon_intersect feature class.&amp;nbsp; When opening the attribute table after the script runs the new field does not show.&amp;nbsp; I can open ArcCatalog and view the table and the field shows.&amp;nbsp; Does anyone know of a different way to refresh the feature class other than what my code is doing.&amp;nbsp; The refresh does not work and the only way to see the new field is to remove the feature class from the TOC and then add it back.&amp;nbsp; I have posted my code below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; import arcpy from arcpy import env from arcpy import mapping&amp;nbsp; arcpy.env.overwriteOutput = True&amp;nbsp; # Set Local Variable&amp;nbsp; A = "\\\\Admingis\\E\\GISDATA\\Projects\\AG\\AgAssess.gdb\\polygon_intersect" mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp; # Create attribute called Acres&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(A): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(A, "Acres", "DOUBLE") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Acres Attribute Added"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Acres Field Not Added"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except arcpy.ExecuteError: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Error Occured Add Acres Attribute Failed" &amp;nbsp;&amp;nbsp;&amp;nbsp; print (arcpy.GetMessages(2)) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create curser to update acres field&amp;nbsp; cur = arcpy.UpdateCursor(A)&amp;nbsp; # Pass through each row to update acres value&amp;nbsp; try:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(A):&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cur: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Acres = row.Shape_Area /43560 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow(row) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Acres Updated"&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Acres Not Updated Feature Class Does Not Exist"&amp;nbsp; except arcpy.ExecuteError: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Error Occured Update Failed" &amp;nbsp;&amp;nbsp;&amp;nbsp; print (arcpy.GetMessages(2))&amp;nbsp; del cur, row&amp;nbsp; arcpy.RefreshCatalog(A) arcpy.RefreshActiveView() arcpy.RefreshTOC()&amp;nbsp; # Delete cursor and objects&amp;nbsp; del arcpy, env, A, mxd &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 14:44:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489173#M38266</guid>
      <dc:creator>BRIANRITTER</dc:creator>
      <dc:date>2012-02-06T14:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh Layer After Adding Field</title>
      <link>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489174#M38267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not sure why it made a difference but I changed my variable path to r"\\......" and removed the slashes that were not needed using r, and it started working.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 15:59:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489174#M38267</guid>
      <dc:creator>BRIANRITTER</dc:creator>
      <dc:date>2012-02-06T15:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Refresh Layer After Adding Field</title>
      <link>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489175#M38268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you post your tools parameters values for this tool please?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 20:46:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/refresh-layer-after-adding-field/m-p/489175#M38268</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2012-08-08T20:46:47Z</dc:date>
    </item>
  </channel>
</rss>

