Friday 25 January 2019

arcpy - GetCount_management() from ArcGIS ToolValidator?


We want to check if feature classes are empty in the ToolValidator.


When you call GetCount_managment() and background processing is on, there is a popup from our validation step.


Is there a different method to find if a feature class is empty, other than using GetCount_management?



Answer



Try a search cursor?


class ToolValidator:

def __init__(self):
import arcpy

self.params = arcpy.GetParameterInfo()

def initializeParameters(self):
fc = self.params[0]
rows = arcpy.SearchCursor(fc)
if rows.next(): #At least one feature
#Do something
else:
#Do something else
return

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...