Monday 30 December 2019

arcgis 10.0 - Permanently replace/update server/service in each ArcSDE Layer in MXD?


Using the mxd.findAndReplaceWorkspacePaths method, if and MXD is updated and the path the the .sde connection file moves again all of the data sources will break again.


Is there a method to permanently update each SDE layer in an MXD Table of Contents to permanently store the SDE Server and Service? Ie. Just replace the SERVER and INSTANCE for each SDE layer in an MXD using python or ArcObjects in Pyhton?



Answer




I have found a solution to breaking the dependence on path to the .sde connection file using ArcPy and the following method.


This way works:


lyr.replaceDataSource(sdeConn, "SDE_WORKSPACE", lyr.datasetName, False)
table.replaceDataSource(sdeConn, "SDE_WORKSPACE", lyr.datasetName, False)

You can rename or delete the connection file after the MXD has been repaired and saved. It will continue to open without issue after the connection file is no longer there.


These methods DO NOT work:


mxd.findAndReplaceWorkspacePaths
lyr.findAndReplaceWorkspacePath


You CANNOT rename or delete the connection file after the MXD has been repaired. The MXD will look for the .sde connection file in the same location always each time it's opened.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...