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
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.