desc = arcpy.Describe(lyr) if len(desc.FIDSet) > 0: # layer has selection doSomething else: doSomethingElse
def count_selection(lyr): """Returns a count of selected features from an input feature layer.""" count = 0 rows = arcpy.SearchCursor(lyr) for row in rows: count += 1 return count
lyr = "Buildings_lyr" if count_selection(lyr) == 0: print lyr, "is empty"
selectcount= int(arcpy.GetCount_management(layer).getOutput(0)) if selectcount != 0: do something if a selection else: do something else if no selection
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.