<?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: Solving my arcpy.updateLayers problem, then looping the solution... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219402#M16889</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added "&lt;SPAN style="background-color: #e4e4ff;"&gt;mxd&lt;/SPAN&gt;.save()" in the end. Solved the first problem, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Apr 2016 00:14:01 GMT</pubDate>
    <dc:creator>AntoineCantin</dc:creator>
    <dc:date>2016-04-06T00:14:01Z</dc:date>
    <item>
      <title>Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219400#M16887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Part A: I'm trying to use the code above to update layers in a mxd using a .lyr file. These layers are in a dataframe named "Couches" (there is another dataframe in the mxd). Code comes from &lt;A href="http://gis.stackexchange.com/a/80981/69986" rel="nofollow noopener noreferrer" target="_blank"&gt;this &lt;/A&gt;post.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy.mapping &lt;SPAN style="color: #000080; font-weight: bold;"&gt;as &lt;/SPAN&gt;mmap

mxd = mmap.MapDocument(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"C:/Users/enclume/Carto/Cartes/UpdateTest/P_5_1.mxd"&lt;/SPAN&gt;)
DF = mmap.ListDataFrames(mxd, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Couches"&lt;/SPAN&gt;)[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]
sourcely = mmap.Layer(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"C:/Users/enclume/Carto/Cartes/Templates/Couches.lyr"&lt;/SPAN&gt;)
ly = mmap.ListLayers(mxd)[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]
mmap.UpdateLayer(DF, ly, sourcely, &lt;SPAN style="color: #000080;"&gt;False&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the code everything seems fine, no error message. But when I open the mxd, nothing has changed. What am I doing wrong? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part B: Once the problem is solved, I would like to loop this code so that it would update all mxd's in a file. How would you proceed to loop it? I saw some stuff &lt;A href="http://gis.stackexchange.com/questions/65395/python-arcmap-fastest-method-to-loop-over-mxds" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;, but I'm far from really understanding how to apply this example to my situation. The person who wrote the code linked above mentioned the glob.glob function to loop it, but I can't find anything about it. Does anyone know how to use it?&lt;/P&gt;&lt;P&gt;If my mxd's folder (&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #f4eaea;"&gt;"C:/Users/enclume/Carto/Cartes/UpdateTest") &lt;/SPAN&gt;contains some subfolders, will the looping function find all the mxd's in the folder and subfolders? &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I'm new to arcpy so please be indulgent and precise...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219400#M16887</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2021-12-11T10:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219401#M16888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;well according to this &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatelayer.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatelayer.htm"&gt;UpdateLayer—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;it looks like the changes won't persist unless the mxd is updated... check the code examples in that link&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 00:02:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219401#M16888</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-06T00:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219402#M16889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added "&lt;SPAN style="background-color: #e4e4ff;"&gt;mxd&lt;/SPAN&gt;.save()" in the end. Solved the first problem, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 00:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219402#M16889</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-04-06T00:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219403#M16890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;good! ...marking the answer that solved the question, as correct, would allow others find the solution should it arise with others.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 00:34:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219403#M16890</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-06T00:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219404#M16891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On another forum, someone wrote me the following code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

MxdFolderPath = arcpy.GetParameterAsText(&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;MxdFolderPath == &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'#' &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;or not &lt;/SPAN&gt;MxdFolderPath:
&amp;nbsp; MxdFolderPath = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"C://Users//enclume//Carto//Cartes//UpdateTest"
&lt;/SPAN&gt;MxdCount = &lt;SPAN style="color: #0000ff;"&gt;0
&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;
&lt;/SPAN&gt;sourcelypath = arcpy.GetParameterAsText(&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;sourcelypath == &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'#' &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;or not &lt;/SPAN&gt;sourcelypath:
&amp;nbsp; sourcelypath = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"C://Users//enclume//Carto//Cartes//Templates//Couches.lyr"
&lt;/SPAN&gt;sourcely = arcpy.mapping.Layer(sourcelypath)

arcpy.env.workspace = MxdFolderPath
arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" MXD PROCESSING"&lt;/SPAN&gt;)
mxdList = arcpy.ListFiles(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"*.mxd"&lt;/SPAN&gt;)
Mxdlen = &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(mxdList)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;Mxdlen == &lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;:
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" There are no mxd in: " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(MxdFolderPath))
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;else&lt;/SPAN&gt;:
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" There are " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(Mxdlen) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;" mxd in: " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(MxdFolderPath))

&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;mxd &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;mxdList:
&amp;nbsp; MxdCount = (MxdCount + &lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;)
&amp;nbsp; processingmxd = arcpy.mapping.MapDocument(mxd)
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" Mxd: " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(MxdCount) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;" :" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(mxd))
&amp;nbsp; dflist = arcpy.mapping.ListDataFrames(processingmxd, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Couches"&lt;/SPAN&gt;)
&amp;nbsp; layercount = &lt;SPAN style="color: #0000ff;"&gt;0
&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;df &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;dflist:
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" df: " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(df.name))
&amp;nbsp; layers = arcpy.mapping.ListLayers(processingmxd, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Couches"&lt;/SPAN&gt;, df)&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# layers called Couches
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;layer &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;layers:
&amp;nbsp; layercount = (layercount + &lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;)
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" Layer: " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(layer))
&amp;nbsp; arcpy.mapping.UpdateLayer(df, layer, sourcely, &lt;SPAN style="color: #000080;"&gt;False&lt;/SPAN&gt;)
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" Layer Updated"&lt;/SPAN&gt;)
&amp;nbsp; processingmxd.save()
&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" "&lt;/SPAN&gt;)
arcpy.AddMessage(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;" End"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;Seems good, but I get an error message: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgba(248, 248, 248, 0.6);"&gt;Traceback (most recent call last): File "&amp;lt;string&amp;gt;", line 24, in &amp;lt;module&amp;gt; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\arcobjects\mixins.py", line 611, in &lt;/SPAN&gt;&lt;STRONG style="font-size: 13px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;init&lt;/STRONG&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgba(248, 248, 248, 0.6);"&gt; assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename") AssertionError: Invalid MXD filename&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Can anyone see where is the problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219404#M16891</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2021-12-11T10:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219405#M16892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For one, check the indentation throughout.&amp;nbsp; for example, line 22, the "for" is indented further than the lines folloiwing.&amp;nbsp; Python is very specific when it comes to indentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but also right off the bat, I don't see where you set mxd.&lt;/P&gt;&lt;P&gt;if running from an open map doc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14599072677375472" data-renderedposition="164_8_1054_16" jivemacro_uid="_14599072677375472"&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: never mind, I see you looping thru the mxdlist.&amp;nbsp;&amp;nbsp; then, just work on the indentation first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 01:48:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219405#M16892</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-04-06T01:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219406#M16893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The identation is a copy/paste problem. It's probably my web browser but once code is added in a comment/post, it appears all messed up. Code lines are doubled and overlapping, I can't modify it. Originally it is indented as shown here: &lt;IMG __jive_id="194024" alt="updatelayers.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/194024_updatelayers.JPG" style="width: 620px; height: 545px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 01:56:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219406#M16893</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2016-04-06T01:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219407#M16894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hope you posted the error over there...&lt;/P&gt;&lt;P&gt;also it is double backslashes \\ for paths, not double foreslashes //&lt;/P&gt;&lt;P&gt;or use 'raw' notation r'c:\somepath\somfile'&amp;nbsp; r is for raw&lt;/P&gt;&lt;P&gt;the error indicates the filename is wrong.&amp;nbsp; so check your environments, paths if using the mxd from disk etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Apr 2016 03:27:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219407#M16894</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-06T03:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Solving my arcpy.updateLayers problem, then looping the solution...</title>
      <link>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219408#M16895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Working! Now, I have to figure out how to insert a folder crawl. Thanks everyone!&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os


MxdFolderPath = arcpy.GetParameterAsText(0)
if MxdFolderPath == '#' or not MxdFolderPath:
&amp;nbsp;&amp;nbsp;&amp;nbsp; MxdFolderPath = "C://Users//enclume//Carto//Cartes//UpdateTest"
MxdCount = 0


sourcelypath = arcpy.GetParameterAsText(1)
if sourcelypath == '#' or not sourcelypath:
&amp;nbsp;&amp;nbsp;&amp;nbsp; sourcelypath = "C://Users//enclume//Carto//Cartes//Templates//Couches.lyr"
sourcely = arcpy.mapping.Layer(sourcelypath)


arcpy.env.workspace = MxdFolderPath
arcpy.AddMessage("&amp;nbsp;&amp;nbsp; MXD PROCESSING")
mxdList = arcpy.ListFiles("*.mxd")
Mxdlen = len(mxdList)
if Mxdlen == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp; There are no mxd in: " + str(MxdFolderPath))
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("&amp;nbsp;&amp;nbsp; There are " + str(Mxdlen) + " mxd in: " + str(MxdFolderPath))


&amp;nbsp;&amp;nbsp;&amp;nbsp; for mxd in mxdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MxdCount = (MxdCount + 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MxdPPath = os.path.join(MxdFolderPath, mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processingmxd = arcpy.mapping.MapDocument(MxdPPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(" Mxd: " + str(MxdCount) + " :" + str(mxd))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dflist = arcpy.mapping.ListDataFrames(processingmxd, "Couches")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in dflist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(" df: " + str(df.name))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(processingmxd, "Couches", df)&amp;nbsp; # layers called Couches
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for layer in layers:
&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("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer: " + str(layer))
&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.mapping.UpdateLayer(df, layer, sourcely, False)
&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("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer Updated")
&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; processingmxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(" ")
arcpy.AddMessage(" End")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/solving-my-arcpy-updatelayers-problem-then-looping/m-p/219408#M16895</guid>
      <dc:creator>AntoineCantin</dc:creator>
      <dc:date>2021-12-11T10:42:21Z</dc:date>
    </item>
  </channel>
</rss>

