POST
|
Thank you for the quick response. This was exactly what I was looking for. Thanks again!
... View more
07-20-2012
12:11 PM
|
0
|
0
|
173
|
POST
|
Hi all, I have inherited some SDE databases that have multiples of the same domain like domain_1, domain_2, domain_3, etc. I was wondering if there was a way to see what feature classes are using the domains so I can update the feature classes to be using the same domain instead of having multiples of the same domain. Thanks in advance
... View more
07-20-2012
07:51 AM
|
0
|
2
|
353
|
POST
|
Great question, try this: import arcpy, os parentDir = r"c:\some\path" for (path, dirs, files) in os.walk(parentDir): >>for file in files: >>>>if file.lower().endswith(".mxd"): >>>>>>mxd = arcpy.mapping.MapDocument(os.path.join(path, file)) >>>>>>print mxd.filePath Get rid of the ">>" symbols. Hope this helps, Jeff I have been trying to add this to the code because I want to have the script search folders within a folder as well. Unfortunately I have been unsuccessful in making this happen. Where exactly do I need to put this in the code for it to work? import arcpy, datetime, os try: arcpy.gp.overwriteOutput = True #Read input parameters from GP dialog folderPath = arcpy.GetParameterAsText(0) output = arcpy.GetParameterAsText(1) #Create an output file outFile = open(output, "w") #Report header outFile.write("MXD REPORT: \n") outFile.write("\n") outFile.write("This report is for all MXDs in a folder. It lists relevant information about\n") outFile.write("map document properties, data frame, layer, and table information for each MXD\n") outFile.write("in a system folder\n") outFile.write("\n") outFile.write("Date: " + str(datetime.datetime.today().strftime("%B %d, %Y")) + "\n") #Loop through each MXD file count = 0 for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) if os.path.isfile(fullpath): if filename.lower().endswith(".mxd"): #Reference MXD mxd = arcpy.mapping.MapDocument(fullpath) count = 1 #Format output value if mxd.author =="": authorValue = "None" else: authorValue = mxd.author if mxd.summary =="": summaryValue = "None" else: summaryValue = mxd.summary BDS = arcpy.mapping.ListBrokenDataSources(mxd) if len(BDS) == 0: BDSValue = "None" else: BDSValue = "A total of " + str(len(BDS)) + " broken data source(s)." #Write MXD data to file outFile.write("\n") outFile.write("\n") outFile.write("------------------------------------------------------------------- \n") outFile.write("MAPDOCUMENT: " + os.path.basename(mxd.filePath) + "\n") outFile.write("------------------------------------------------------------------- \n") outFile.write("\n") outFile.write("\t Path: " + mxd.filePath + "\n") outFile.write("\t Last Saved: " + str(mxd.dateSaved) + "\n") outFile.write("\t Author: " + authorValue + "\n") outFile.write("\t Summary: " + summaryValue + "\n") outFile.write("\t Relative Paths: " + str(mxd.relativePaths) + "\n") outFile.write("\t Broken Data Sources: " + BDSValue + "\n") #Reference each data frame and report data DFList = arcpy.mapping.ListDataFrames(mxd) for df in DFList: #Format output values if df.description == "": descValue = "None" else: descValue = df.description #Write data frame data to file outFile.write("\n") outFile.write("\n") outFile.write("\t DATA FRAME: " + df.name + "\n") outFile.write("\n") outFile.write("\t\t Description: " + descValue + "\n") outFile.write("\t\t Spatial Reference: " + df.spatialReference.name + "\n") outFile.write("\t\t Transformation(s): " + str(df.geographicTransformations) + "\n") outFile.write("\t\t Map Units: " + df.mapUnits + "\n") try: outFile.write("\t\t Scale: " + str(df.scale) + "\n") except: outFile.write("\t\t Scale: Unknown \n") outFile.write("\t\t Rotation: " + str(df.rotation) + "\n") #Reference each layer in a data frame lyrList = arcpy.mapping.ListLayers(mxd, "", df) for lyr in lyrList: outFile.write("\n") outFile.write("\t\t LAYER: " + lyr.name + "\n") outFile.write("\t\t\t Group Layer Path: " + lyr.longName + "\n") if lyr.supports("dataSource"): outFile.write("\t\t\t Data Source: " + lyr.dataSource + "\n") try: outFile.write("\t\t\t Dataset type: " + arcpy.Describe(lyr.dataSource).datasettype + "\n") except: outFile.write("\t\t\t Dataset type: Unknown (could be a broken data source) \n") else: outFile.write("\t\t\t Data Source: N/A \n") if lyr.supports("definitionQuery"): if lyr.definitionQuery == "": outFile.write("\t\t\t Query Definition: None \n" ) else: outFile.write("\t\t\t Query Definition: " + lyr.definitionQuery + "\n") else: outFile.write("\t\t\t Query Definition: N/A \n") #Reference each table in a data frame tableList = arcpy.mapping.ListTableViews(mxd, df, "") for table in tableList: outFile.write("\n") outFile.write("\n") outFile.write("\t\t TABLEVIEW: " + table.name + "\n") outFile.write("\n") outFile.write("\t\t\t Data Source: " + table.dataSource + "\n") if table.definitionQuery == "": outFile.write("\t\t\t Query Definition: None \n") else: outFile.write("\t\t\t Query Definition: " + table.definitionQuery + "\n") del mxd if count ==0: outFile.write("\n") outFile.write("\n") outFile.write("---------------------------------------------------------------------------------- \n") outFile.write(" NO MXD FILES FOUND \n") outFile.write("---------------------------------------------------------------------------------- \n") outFile.close() #Open resulting text file os.startfile(output) #Delete variables that reference data on disk del folderPath, output, outFile, fullpath except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e)) Thanks for your help, Tim
... View more
08-24-2011
09:39 AM
|
0
|
0
|
1659
|
POST
|
Hi, I am geocoding a list of addresses using two different geocoders. One is US Streets and the other is US Alphanumeric Ranges. After geocoding, the alpha geocoder does not place addresses that the numeric locator places. Why is that? Thanks, Tim
... View more
12-08-2010
10:01 AM
|
0
|
1
|
701
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|