<?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: UpdateLayer Assertion Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updatelayer-assertion-error/m-p/96275#M7468</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Instead of using strings for the input paramaters in UpdateLayer, use actual data frame and layer objects. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.UpdateLayer(df, insertLayer, soilsLayer, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed in your code, you already have a reference to a data frame and the SoilsClip layer - so you can use those, as I have above. However, you will also need to make a reference to the Soils layer, similar to how you referenced the SoilsClip layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out the syntax here for UpdateLayer: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;SPAN&gt;. The paramater explanations have links to the Layer class help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jul 2012 21:23:21 GMT</pubDate>
    <dc:creator>JeffMoulds</dc:creator>
    <dc:date>2012-07-02T21:23:21Z</dc:date>
    <item>
      <title>UpdateLayer Assertion Error</title>
      <link>https://community.esri.com/t5/python-questions/updatelayer-assertion-error/m-p/96274#M7467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am writing some code to clip a soils layer based on a selected boundray polygon and want the clipped soils layer "SoilsClip" to have the same symbology and label properties as the source layer "Soils".&amp;nbsp; i am using the UpdateLayer command and keep getting an Assertion Error.&amp;nbsp; Please provide any help you can.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Import modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set Map Document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set Overwrite Option&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create Map Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management("Boundary", "Boundary_Selection.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Add Boundary Selection Layer to Layers Data Frame&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer = arcpy.mapping.Layer("Boundary_Selection.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df, addLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set Boundary Selection symbology&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SymbologyLayer = ("Boundary")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = ("Boundary_Selection.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ApplySymbologyFromLayer_management (lyr, SymbologyLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set Layers data frame extent and scale&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.ListLayers(mxd, "Boundary", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.extent = lyr.getSelectedExtent(False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.scale = df.scale * 1.15&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Refresh map to show changes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;###################################################################&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Clip Soils layer, **goes to default gdb**&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Clip_analysis("Soils", "Boundary_Selection.lyr", "SoilsClip")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Insert Layer below Boundary_Selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;refLayer = arcpy.mapping.ListLayers(mxd, "Boundary", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;insertLayer = arcpy.mapping.Layer("SoilsClip")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.InsertLayer(df, refLayer, insertLayer, "AFTER")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set Soils Clip Layer symbology&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#SymbologyLayer = ("Soils")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#lyr = ("SoilsClip")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#arcpy.ApplySymbologyFromLayer_management (lyr, SymbologyLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Refresh map to show changes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Update SoilsClip Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.UpdateLayer("Layers", "SoilsClip", "Soils", False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Refresh map to show changes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 15:27:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatelayer-assertion-error/m-p/96274#M7467</guid>
      <dc:creator>AllenSmith</dc:creator>
      <dc:date>2012-07-02T15:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateLayer Assertion Error</title>
      <link>https://community.esri.com/t5/python-questions/updatelayer-assertion-error/m-p/96275#M7468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Instead of using strings for the input paramaters in UpdateLayer, use actual data frame and layer objects. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.UpdateLayer(df, insertLayer, soilsLayer, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed in your code, you already have a reference to a data frame and the SoilsClip layer - so you can use those, as I have above. However, you will also need to make a reference to the Soils layer, similar to how you referenced the SoilsClip layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Check out the syntax here for UpdateLayer: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;SPAN&gt;. The paramater explanations have links to the Layer class help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 21:23:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatelayer-assertion-error/m-p/96275#M7468</guid>
      <dc:creator>JeffMoulds</dc:creator>
      <dc:date>2012-07-02T21:23:21Z</dc:date>
    </item>
  </channel>
</rss>

