<?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: Bug with arcpy.mapping.UpdateLayer() method ?? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432322#M33992</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From what I can tell, setting&amp;nbsp; 'update symbology only' is set to False' tells it to update everything in the layer, including name.&amp;nbsp; In fact, if you point to a different FC, it would replace it even.&amp;nbsp; As the help doc says, basically, it is doing a remove layer/add layer with the new properties as defined in the layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think, if you want to use the updatelayer for this, you might either have to re-create the layer file with python before applying it so that the name is representative of your data, OR, keep the original layer name in a variable, updateLayer, then rename the layer back to what it was before moving on to the next one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jul 2013 22:00:46 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2013-07-22T22:00:46Z</dc:date>
    <item>
      <title>Bug with arcpy.mapping.UpdateLayer() method ??</title>
      <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432321#M33991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings and Salutations Python Masters of the Universe,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe I have a minor bug here with the arcpy.mapping.UpdateLayer() method.&amp;nbsp; If anyone can help me correct it or work around it I would greatly appreciate it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not going to post the code because it is a simple script.&amp;nbsp; Basically I use the UpdateLayer method to update a whole bunch of layers, about 150, and the 'update symbology only' is set to False.&amp;nbsp; I'm updating everything; each layer comes from a different feature class for different counties so the database schema is the same for each.&amp;nbsp; I use the UpdateLayer to hide fields on all the layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, after updating, the name for each layer is now based on the original layer that I used as the Source Layer.&amp;nbsp; Well, this is where the fun part comes in, whenever I go to change any of the names they all change based on whatever the one has been changed to. If I go to one of the layer's properties and change the name, it then changes the name of every single layer.&amp;nbsp; I've copied all the layers into another data frame to copy so I can loop through and set the names to be equal but it won't work because of this bug.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, the layer name changes for every layer when only one has been changed after using the UpdateLayer method on the layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GIS Python Padewan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 18:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432321#M33991</guid>
      <dc:creator>ThomasMcCracken</dc:creator>
      <dc:date>2013-07-22T18:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Bug with arcpy.mapping.UpdateLayer() method ??</title>
      <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432322#M33992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From what I can tell, setting&amp;nbsp; 'update symbology only' is set to False' tells it to update everything in the layer, including name.&amp;nbsp; In fact, if you point to a different FC, it would replace it even.&amp;nbsp; As the help doc says, basically, it is doing a remove layer/add layer with the new properties as defined in the layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think, if you want to use the updatelayer for this, you might either have to re-create the layer file with python before applying it so that the name is representative of your data, OR, keep the original layer name in a variable, updateLayer, then rename the layer back to what it was before moving on to the next one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 22:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432322#M33992</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-22T22:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Bug with arcpy.mapping.UpdateLayer() method ??</title>
      <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432323#M33993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're misunderstanding my bug...I know the UpdateLayer will change the name; that's not the problem.&amp;nbsp; The problem is the name will change for every layer after the method has been used whenever I change one of the layer's names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I did save the name in a variable and reapplied like you said, what happens is every layer gets the name of the last layer named whatever that name may be.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I go manually into one of the layers, any of them, and change the name then every single layer that has been updated with the UpdateLayer method also changes its name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2013 11:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432323#M33993</guid>
      <dc:creator>ThomasMcCracken</dc:creator>
      <dc:date>2013-07-23T11:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Bug with arcpy.mapping.UpdateLayer() method ??</title>
      <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432324#M33994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I could reproduce your naming one / name all problem.&amp;nbsp; I fixed it by placing the reference to the layer file within my loop and deleting the variable before the next iteration.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os mxd = arcpy.mapping.MapDocument(r"C:\Temp\Test.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] for lyr in arcpy.mapping.ListLayers(mxd): &amp;nbsp; lyrFile = arcpy.mapping.Layer(r"C:\Temp\Test.lyr")&amp;nbsp; &amp;nbsp; layerName = lyr.name &amp;nbsp; arcpy.mapping.UpdateLayer(df, lyr, lyrFile, False) &amp;nbsp; lyr.name = layerName &amp;nbsp; del lyrFile mxd.saveACopy(r"C:\Temp\Test2.mxd") del mxd os.startfile(r"C:\Temp\Test2.mxd")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd really like to understand the utility of updating 100+ layers so they are all identical except for their name.&amp;nbsp; When we designed UpdateLayer we were thinking of scenarios where a single layer either in one MXD or across many MXDs would be updated.&amp;nbsp; I'd like to learn more about your scenario.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2013 13:37:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432324#M33994</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2013-07-23T13:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Bug with arcpy.mapping.UpdateLayer() method ??</title>
      <link>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432325#M33995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Woo ha it worked!&amp;nbsp; Thank you very much; I tried doing the same thing in my loop with the name but I always left the source layer variable outside the loop so it never deleted.&amp;nbsp; It's strange though because I did close the mxd and re-open so that the variable was lost and I still got the crazy name change bug.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, here is the scenario I'm working with.&amp;nbsp; I have a file geodatabase with parcel data divided into 150 features classes-one for each county.&amp;nbsp; These all have the same database schema; I guess they divided it by county for size or ease of distribution, who knows.&amp;nbsp; So these feature classes have around 100 records or so that our users don't need to see.&amp;nbsp; Some of it is the sales data and other information that is provided by local governments.&amp;nbsp; I needed to remove all the fields except for about 20 and this is why I used the UpdateLayer function in Python so I wouldn't have to do it 150 times.&amp;nbsp; Now that I have the layers updated properly I'm going to share it as a service with ArcGIS Server.&amp;nbsp; Maybe there's a more appropriate method in the ArcPy module but I couldn't find it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have anymore questions feel free to shoot them at me.&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>Tue, 23 Jul 2013 14:24:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-with-arcpy-mapping-updatelayer-method/m-p/432325#M33995</guid>
      <dc:creator>ThomasMcCracken</dc:creator>
      <dc:date>2013-07-23T14:24:22Z</dc:date>
    </item>
  </channel>
</rss>

