<?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: Buffer not added to map in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505001#M39669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can try using the make feature layer tool (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006p000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006p000000&lt;/A&gt;&lt;SPAN&gt;) then updating the amphibology (edit: &lt;/SPAN&gt;&lt;STRONG&gt;symbology &lt;/STRONG&gt;&lt;SPAN&gt;of course, darn autocorrect, but was too funny to delete out) with the existing layer you have. If I am following what you are trying to accomplish.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Mar 2012 15:45:35 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2012-03-28T15:45:35Z</dc:date>
    <item>
      <title>Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/504998#M39666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When creating a buffer in a script, isn't it supposed to be added to the map by default? The code below creates the buffer just fine, but I have to add it to the map manually. Neither refreshing via code or with F5 or View - Refresh helps. I think this is the reason setting update_layer in the try block doesn't work. I know it's update_layer throwing the error because when I included it in the error message, that threw an error stating update_layer was undefined. Code &amp;amp; error below. Thanks for any ideas.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; import arcpy from arcpy import env&amp;nbsp; env.workspace = r"\\TestServer\TestCases_Geodatabase.gdb" mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&amp;nbsp; case_number = arcpy.GetParameterAsText(0) #------------------------------------------------------------------------------- # Buffer Processing # def CreateBuffer(): &amp;nbsp;&amp;nbsp;&amp;nbsp; # set buffer parameters &amp;nbsp;&amp;nbsp;&amp;nbsp; case = "Cases" &amp;nbsp;&amp;nbsp;&amp;nbsp; output ="Buffer_200" &amp;nbsp;&amp;nbsp;&amp;nbsp; dist = "200 feet" &amp;nbsp;&amp;nbsp;&amp;nbsp; side = "OUTSIDE_ONLY"&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # delete existing temporary buffer, if any &amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(output): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(output)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # create buffer &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(case, output, dist, side)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # update symbology &amp;nbsp;&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source_layer = r"\\TestServer\Map Templates\GIS_Lyr_Files\Buffer.lyr" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_layer = arcpy.mapping.ListLayers(mxd, "B*", df)[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(df, update_layer, source_layer, True) &amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as e: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Updating symbology \n sl = " + source_layer + "\n" + e.message)&amp;nbsp; def main(): &amp;nbsp;&amp;nbsp;&amp;nbsp; CreateBuffer()&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshTOC &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView&amp;nbsp; if __name__ == '__main__': &amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Updating symbology&amp;nbsp;&amp;nbsp; sl = \\TestServer\Map Templates\GIS_Lyr_Files\Buffer.lyr list index out of range Completed script Buffer200... Failed to execute (Buffer200). Failed at Wed Mar 28 08:22:06 2012 (Elapsed Time: 56.00 seconds)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 12:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/504998#M39666</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2012-03-28T12:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/504999#M39667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To make that automatic, without adding any code, I believe you need to change the setting in ArcMap under Geoprocessing &amp;gt; Geoprocessing Options "Add results of geoprocessing operations to the display"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 14:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/504999#M39667</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-03-28T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505000#M39668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, that's a good thing to double check. The box in options is checked, though, so doesn't seem to be the issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 15:39:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505000#M39668</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2012-03-28T15:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505001#M39669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can try using the make feature layer tool (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006p000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006p000000&lt;/A&gt;&lt;SPAN&gt;) then updating the amphibology (edit: &lt;/SPAN&gt;&lt;STRONG&gt;symbology &lt;/STRONG&gt;&lt;SPAN&gt;of course, darn autocorrect, but was too funny to delete out) with the existing layer you have. If I am following what you are trying to accomplish.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 15:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505001#M39669</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-03-28T15:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505002#M39670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, I'll look at that. My goal is to create a 200' buffer (that's working), display it on the map (nope, should be default?) and symbolize it based on a .lyr file - 2.00 red line (also no, although my guess is that's because the buffer itself doesn't show up).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Making another layer seems redundant, especially when it's not a problem to do manually, but maybe that's how it'll have to be. In tutorials the buffer layer always shows up. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This leads me into a pet peeve about ArcGIS help. It sometimes uses the term layer to refer to a layer in the map - shapefile, feature class, etc - and sometimes to only refer to a .lyr file only. Kind of sloppy editing there. Also, why have to use a .lyr file for operations that manually can use feature classes? Maybe 10.1 will do something about this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 16:06:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505002#M39670</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2012-03-28T16:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505003#M39671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think your problem is stemming from the fact that ArcMap isn't smart enough to figure out that a path to a .lyr is a "Layer Object". You need to add arcpy.mapping.Layer() statements to make it clear. This is what I have for inside your try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source_layer = "H:/GIS_Data/Buffer.lyr" # point to your own .lyr &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceLayer = arcpy.mapping.Layer(source_layer)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(output, "Buffs") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addLayer = arcpy.mapping.Layer("Buffs")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df,addLayer) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_layer = arcpy.mapping.ListLayers(mxd, "Buffs", df)[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(source_layer) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(df, update_layer, sourceLayer, True)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 16:16:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505003#M39671</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-03-28T16:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Buffer not added to map</title>
      <link>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505004#M39672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well that does the job! Thanks Darren &amp;amp; Mathew, I very much appreciate it. Wish I could mark both posts as an answer, but gave both points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm going to go through the code to see exactly what it's doing; still don't know why the buffer wouldn't be added automatically, but whatever. It's working and will make my job in the future much easier by letting others run the script and stop asking me to do it for them manually.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 16:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/buffer-not-added-to-map/m-p/505004#M39672</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2012-03-28T16:51:45Z</dc:date>
    </item>
  </channel>
</rss>

