I used the same source but got a big exception during line replaceDataSource
import os, arcpy masterPath = "C:\\MXDs" sites = os.listdir(sitesPath) for site in sites: if ".mxd" in site or ".MXD" in site: #checks if file is a map document mxd = arcpy.mapping.MapDocument(masterPath+"\\"+site) #========== #do stuff to MXDs here: #========== mxd.save() del mxd
for lyr in arcpy.mapping.ListLayers(mxd): if lyr.isFeatureLayer and ".sde" in lyr.dataSource: #'isGroupLayer' must be tested before 'dataSource' lyr.replaceDataSource(newPathSDE, "SDE_WORKSPACE", lyr.datasetName)
mxd.replaceWorkspaces("C:\\connections\\OldSDEconnection.sde", "SDE_WORKSPACE", "C:\\connections\\NewSDEconnection.sde", "SDE_WORKSPACE")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.