def getLists(): dsList = arcpy.ListDatasets("*") for ds in dsList: dsName = ds.split(".") print dsName[2].upper() print " - Feature Classes" fcList = arcpy.ListFeatureClasses("*", "", ds) if len(fcList) == 0: print "\t - " + "No feature class in this dataset. \n" continue for fc in fcList: desc = arcpy.Describe(fc) if desc.featureType == "Simple": fcName = fc.split(".") desc = arcpy.Describe(fc) print "\t - " + fcName[2] + ": " + desc.shapeType print "\n"
Solved! Go to Solution.
import arcpy, gc # Write results to a textfile logfile = open(r'C:\TEMP\List_FCs_in_FDs.log', 'w') def log_results(message): print(message) logfile.write(message) logfile.flush() return def main(): try: EGDB = arcpy.env.workspace = r'Database Connections\ORCL - SDE@SERVER.sde' fdList = arcpy.ListDatasets("*", "Feature") fdCnt = 0 totalFCcnt = 0 if arcpy.Exists(EGDB) == True: for eachFD in sorted(fdList) : fdCnt += 1 log_results("\n {0}. Feature Dataset '{1}'\n".format(str(fdCnt),eachFD)) fcCnt = 0 # Cannot use fdEGDB = EGDB + '/' + eachFD returns Cartesian Product fdEGDB = arcpy.env.workspace = EGDB + '/' + eachFD fcList = arcpy.ListFeatureClasses("*") for eachFC in sorted(fcList): desc = arcpy.Describe(eachFC) log_results(" -> " + eachFC + ' (' + desc.shapeType + ')') fcCnt += 1 totalFCcnt += 1 if fcCnt == 0: log_results("\n Feature Dataset '{0}' does not contain any Feature Classes!!\n".format(eachFD)) else: log_results("\n # of Feature Classes in the '{0}' Feature Dataset : {1}\n".format(eachFD,str(fcCnt))) log_results("\n TOTAL # OF FEATURE DATASETS COUNTED : {0}".format(str(fdCnt))) log_results(" TOTAL # OF FEATURE CLASSES COUNTED : {0}\n".format(str(totalFCcnt))) else: log_results("\n The specified SDE Connection File DOES NOT EXIST\n") return log_results ("\n\n COMPLETED!! \n\n") del fcCnt del fdCnt del fcList del fdList del fdEGDB del eachFD del totalFCcnt gc.collect() except arcpy.ExecuteError: log_results (arcpy.GetMessages(2)) except Exception as e: log_results (e[0]) if __name__ == '__main__': main()
if desc.dataType=='Topology': continue
import arcpy, gc # Write results to a textfile logfile = open(r'C:\TEMP\List_FCs_in_FDs.log', 'w') def log_results(message): print(message) logfile.write(message) logfile.flush() return def main(): try: EGDB = arcpy.env.workspace = r'Database Connections\ORCL - SDE@SERVER.sde' fdList = arcpy.ListDatasets("*", "Feature") fdCnt = 0 totalFCcnt = 0 if arcpy.Exists(EGDB) == True: for eachFD in sorted(fdList) : fdCnt += 1 log_results("\n {0}. Feature Dataset '{1}'\n".format(str(fdCnt),eachFD)) fcCnt = 0 # Cannot use fdEGDB = EGDB + '/' + eachFD returns Cartesian Product fdEGDB = arcpy.env.workspace = EGDB + '/' + eachFD fcList = arcpy.ListFeatureClasses("*") for eachFC in sorted(fcList): desc = arcpy.Describe(eachFC) log_results(" -> " + eachFC + ' (' + desc.shapeType + ')') fcCnt += 1 totalFCcnt += 1 if fcCnt == 0: log_results("\n Feature Dataset '{0}' does not contain any Feature Classes!!\n".format(eachFD)) else: log_results("\n # of Feature Classes in the '{0}' Feature Dataset : {1}\n".format(eachFD,str(fcCnt))) log_results("\n TOTAL # OF FEATURE DATASETS COUNTED : {0}".format(str(fdCnt))) log_results(" TOTAL # OF FEATURE CLASSES COUNTED : {0}\n".format(str(totalFCcnt))) else: log_results("\n The specified SDE Connection File DOES NOT EXIST\n") return log_results ("\n\n COMPLETED!! \n\n") del fcCnt del fdCnt del fcList del fdList del fdEGDB del eachFD del totalFCcnt gc.collect() except arcpy.ExecuteError: log_results (arcpy.GetMessages(2)) except Exception as e: log_results (e[0]) if __name__ == '__main__': main()