Tuesday, 11 September 2018

arcpy - Adding error message to parameter if seperate derived multivalue parameter is empty using ArcGIS tool validation?



I have three tool parameters;




  1. an input point feature class,

  2. a (multivalue) list of fields derived from the input feature class and

  3. an output file location to export to Excel.


I have filtered the fields derived from the feature so only Short, Long, Float, Double, Text and Date types are accepted. I would like to set the tool validation so that if a point feature class is selected that doesn't contain any fields of said types, an error message will show by the input point feature class parameter. The below code shows where I am at currently however does not present an error message.


  def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""


if self.params[0].altered and str(self.params[0].value) != "":
if not self.params[1].value:
self.params[0].setErrorMessage("The selected feature class does not have any fields. Please check and try again.")
else:
self.params[0].clearMessage()
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...