arcpy.Exists and else statement

المشرف العام

Administrator
طاقم الإدارة
This code will go to WATERLINES.gdb, go through the gdb to see if the fc exist (based on a wildcard query), then add the fc to the mxd as desired. My questions is if the fc doesn't exist, the "else" isn't met. That is, the warning "No Waterline data exist for the PWS." isn't added to the tool dialog. It just keeps running the rest of the code. I'm curious as to why?

# Add waterlinesenv.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"wlFclass = arcpy.ListFeatureClasses(waterlines)for wl in wlFclass: wlPath = os.path.join(env.workspace, wl) if arcpy.Exists(wlPath): arcpy.AddMessage("Waterline data exist for this PWS.") arcpy.MakeFeatureLayer_management(wlPath, wl_layer) arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb) newLayer = arcpy.mapping.Layer(wl_layer) arcpy.mapping.AddLayer(df, newLayer, "TOP") else: arcpy.AddWarning("No waterline data exist for this PWS.")

أكثر...
 
أعلى