<?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: findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd?? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248102#M19183</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you use arcpy.mapping.ListDataframes and iterate through the list that returns to get layers for each DF and run your findandreplace code against those?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Aug 2012 15:44:16 GMT</pubDate>
    <dc:creator>ChristopherThompson</dc:creator>
    <dc:date>2012-08-31T15:44:16Z</dc:date>
    <item>
      <title>findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd??</title>
      <link>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248101#M19182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Got stuck trying to fix broken links in a series of mxds.&amp;nbsp; I found if a map has more than one data frame, the findandreplaceworkspacepaths method is not working, or at least the mxd.save() call isn't saving the changes, even though the code runs without error.&amp;nbsp; Even if I ran code similar below through the arcpy window using the 'current' map object call, and clicking the save icon in ArcMap or performing File-&amp;gt;Save from the File menu in ArcMap does not save any changes.&amp;nbsp; Once I removed all but one data frame from an mxd, the code and all save/save as operations worked fine.&amp;nbsp; Is this a bug, or am I doing something wrong?&amp;nbsp; Thanks ahead of time.&amp;nbsp; I'm using ArcGIS v10sp4, and am just trying to change shapefile workspace paths in an mxd.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a quick code sample:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r'\\filelocation\map.mxd')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.findAndReplaceWorkspacePaths(r'\\filelocation1', r'\\filelocation2')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshTOC&lt;/SPAN&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>Thu, 30 Aug 2012 20:05:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248101#M19182</guid>
      <dc:creator>ChrisStump</dc:creator>
      <dc:date>2012-08-30T20:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd??</title>
      <link>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248102#M19183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you use arcpy.mapping.ListDataframes and iterate through the list that returns to get layers for each DF and run your findandreplace code against those?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 15:44:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248102#M19183</guid>
      <dc:creator>ChristopherThompson</dc:creator>
      <dc:date>2012-08-31T15:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd??</title>
      <link>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248103#M19184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; That's actually how I initially tried to perform this, but can't get the map object to save.&amp;nbsp; The function I have is this to return the list of layers in the data frame:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def list_layers_mxd(self, mxd_path, data_frame = "", layers = ""):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mxd = arcpy.mapping.MapDocument(mxd_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, data_frame)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layers = arcpy.mapping.ListLayers(mxd, layers, df)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layers.sort()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del df&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so I reference that function in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def findreplace_paths_mxd(self, mxd_path, new_path):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layers = deq_gis().list_laerys_mxd(mxd_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(mxd_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in layers[0]:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;old_source = lyr.workspacePath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.findAndReplaceWorkspacePaths(old_source, new_path, 'False')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefrechTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in my mind this should save the changes made to the .mxd, but when I open the saved .mxd nothing has changed.&amp;nbsp; Sometimes it works if referenced in the arcpy window in arcmap, using the 'current' reference.&amp;nbsp; I removed all but one data frame, which helps if run in the desktop but still doesn't do anything in standalone code.&amp;nbsp; Also, saveacopy() creates a new copy but doesn't save the workspace path change.&amp;nbsp; Can't figure out if I'm doing something wrong or if there's a bug in the arcpy class library.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 15:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248103#M19184</guid>
      <dc:creator>ChrisStump</dc:creator>
      <dc:date>2012-08-31T15:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd??</title>
      <link>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248104#M19185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can not reproduce this problem.&amp;nbsp; Our internal tests include MXDs with many DFs.&amp;nbsp; I'm having a difficult time reading your sample code - I see several possible issues with it.&amp;nbsp; Try replacing your data sources with a simple script that does not include functions (not that that is the problem).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See the samples in the following topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2012 16:12:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/findandreplaceworkspacepaths-doesn-t-work-w/m-p/248104#M19185</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-09-04T16:12:49Z</dc:date>
    </item>
  </channel>
</rss>

