I have a tool that has a workspace parameter and accepts multiple values. In the tool validation script, I would like to list all feature classes found within all chosen workspaces in the second parameter.
How do I iterate over the workspaces in the first parameter?
def updateParameters(self):
# Modify parameter values and properties.
# This gets called each time a parameter is modified, before
# standard validation.
if self.params[0].altered:
# something like below ?
for ws in self.params[0].split(";"):
Solved! Go to Solution.
Cheers Dan. Figured it out.
def updateParameters(self):
# Modify parameter values and properties.
# This gets called each time a parameter is modified, before
# standard validation.
self.params[1].filter.list = []
if self.params[0].altered:
if self.params[0].value:
fcs = []
ws = self.params[0].values
for item in ws:
arcpy.env.workspace = item
data = arcpy.da.Walk(item, datatype="FeatureClass")
for dirpath, dirnames, filenames in data:
for filename in filenames:
fcs.append(filename)
self.params[1].filter.list = fcs
return
It was the '.values' property of the multiple value parameter I was missing.
Walk—ArcGIS Pro | Documentation
should pretty well cover the things you are looking for. ListWorkspaces, ListFeatureclasses in conjunction with Walk
Cheers Dan. Figured it out.
def updateParameters(self):
# Modify parameter values and properties.
# This gets called each time a parameter is modified, before
# standard validation.
self.params[1].filter.list = []
if self.params[0].altered:
if self.params[0].value:
fcs = []
ws = self.params[0].values
for item in ws:
arcpy.env.workspace = item
data = arcpy.da.Walk(item, datatype="FeatureClass")
for dirpath, dirnames, filenames in data:
for filename in filenames:
fcs.append(filename)
self.params[1].filter.list = fcs
return
It was the '.values' property of the multiple value parameter I was missing.