I've been working with a .mxd that has some broken links. I have been using the following python to print the workspace path for each layer:
>>> for lyr in arcpy.mapping.ListLayers(mxd):
... if lyr.supports("workspacePath"):
... source = lyr.workspacePath
... print "%s -> %s" % (lyr, source)
I found that layers do successfully get drawn and their data source is correct in arc map even if the workspacePath points to a .sde file that doesn't exist on the machine. If the links aren't broken, then there's no need to fix them; but I'm curious how ArcMap is able to find the data in sde if the layer workspacePath is not correct.
Solved! Go to Solution.
Actually I'm creating a toolbox/Python-addin that makes it pretty easy. I have several tools
1-find GDB in a folder (recursive....each tool does a walk, so includes subfolders)
2-list all feature classes in the folder
3a-list all the (unique) broken links, by type, within all the MXDs in a folder....writting a .txt, .csv, and .xls as output
3b- does same as 3a, but lets you replace all the top level (i.e drive->drive, drive->UNC, etc) before runing the inventory
I use the output of 3a/b to add a column of all the newpaths I need, and new type in the case of changing shape/covers/sde -> FGDB, sde->service etc.
4 - takes modified csv as input .and fixes all the links.
Although I ran 3a on a directory with about 1500+ mxd, 50k+ individual broken links, and about 3k unique broken links, I'm now repairing project by project so I can make sure it works before moving to next project.
To answer your question....30 years of project and data I need to make sure is working after many changes. This is an easy way to do it, and I'm trying to get all the connections to UNC so connections don't break do to different mapping by different users. I think I now have it working for almost every combination...but just starting to put into actual use (vs testing), so may still hit a road block somewhere down the road. and that's why I make sure to back up the mxd's (to a different folder, of course) before running #4.
What you are running into is a bug that was addressed in ArcGIS 10.3, i.e., prior to ArcGIS 10.3 the embedded service properties were not available when an SDE data source was broken. If you try on a 10.3 machine, I would be interested to see the results. Normally I would provide links to documentation, but the Esri Support and Development documentation on this bug is a mess in terms of consistency and accuracy. There is still an open bug with Esri Support even though Esri Development fixed it already.
Thanks Joshua, yes it does work in 10.3. I'm trying to keep my addin working 10.2.2 since I have users that have not upgraded yet. Keeping a toolbox from not automatically thinking it's 10.3 means I need to make sure I do all my "touching of the toolbox" and addin builds on the 10.2.2 machine. The toolbox actually seems to get corrupted for 10.2.2 if I just open it in 10.3....but that is a topic for another day.
Good to know that works though!