We have migrated a bulk of our GIS data from shapefiles into feature classes within feature datasets (ArcGIS-file geodatabase-feature datasets).
I am trying to develop a Python script to automatically replace the most popular datasets in an mxd with the paths to the new data.
My problem is that both the data model (shapefile to feature dataset feature class) has changed, and the feature class name has changed.
The replaceDataSource() and replaceWorkspacePaths() methods do not have parameter for connecting to feature datasets.
See http://help.arcgis.com/en/arcgisdesk...000000n000000/
The code posted below works if I move my feature class out of the feature dataset within the file geodatabase (meaning the syntax is good). Still, how to I set the replaceDataSource to a feature data set?
Code:try: import arcpy.mapping, os, sys, string, traceback mxd = arcpy.mapping.MapDocument("CURRENT") for dataframe in arcpy.mapping.ListDataFrames(mxd): BrokenLinkList = arcpy.mapping.ListBrokenDataSources(dataframe) for item in BrokenLinkList: print item.datasetName if item.datasetName == r"LummiReservationFullBoundary": print "droppin' in" #The path to the new directory... newWorkspace = r"Z:\Data\Boundaries\Administrative\Lummi.gdb\TribalBoundaries" #The new dataset name... datasetName = r"LummiReservation" #This should have a "FEATUREDATASET" options to replace FILEGDB_WORKSPACE. item.replaceDataSource (newWorkspace, "FILEGDB_WORKSPACE", datasetName, False) arcpy.RefreshTOC() #mxd.save() del mxd print "Done" except arcpy.ExecuteError: msgs = arcpy.GetMessages(2) arcpy.AddError(msgs) print msgs except: tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(pymsg) arcpy.AddError(msgs) print pymsg + "\n" print msgs

Reply With Quote


Bookmarks