Using this https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/updatingandfixingdatasources.htm as a guide I am trying to find and replace the datasources in my mxd to enterprise gis sources but the new mxd created just has the same datasources. I tried doing a find and replace to another filegeodatabase but it still isn't doing the replace.
import arcpy... mxd = arcpy.mapping.MapDocument(r'Z:\GIS\scratch\Workspaces_SDE\GDB.mxd')... mxd.findAndReplaceWorkspacePaths(r'K:\Water and Sewer\Services\Services.gdb', r'Z:\GIS\scratch\20210809.gdb')... mxd.saveACopy(r'Z:\GIS\scratch\Workspaces_SDE\SDE.mxd')... del mxd
Is the issue the spaces?
That is good to know but the work around is literally doing it manually something I am trying to avoid lol.
Maybe a bug: BUG-000137385
https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEzNzM4NQ==
That is pretty much what I am doing without the print "done" at the bottom. Not sure what is happening it runs as if it worked with no errors but the datasources are unchanged. I even tried to replace something simple like "K" to "LOL" and it still didn't work (I choose LOL so it would stand out). I even put it in a try statement with an error capture and nothing.Thoughts?
Yeah, I didn't copy the code over probably so you might have missed it but the save copy function is there and it does save a copy but none of the datasources are altered.
I tested the following and it worked for me.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Temp\MxdDataSourceTest.mxd") mxd.findAndReplaceWorkspacePaths(r"C:\Temp\BPs.gdb",r"C:\Temp\BPs_1.gdb") mxd.saveACopy(r"C:\Temp\MxdDataSourceTest2.mxd") print 'done'
You need to save it after.
mxd.save()
mxd.saveACopy(r"C:\Users\SMALIS\Documents\ArcGIS\pythonSwitchSourceNEW.mxd")
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.