def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if self.params[0].value and self.params[1].value:
ds = self.params[0].value
if arcpy.Describe(ds).dataType[:5] != "Table":
out = str(self.params[1].value)
if os.path.splitext(out)[1] == ".dbf":
self.params[1].value = os.path.splitext(out)[0] + ".shp"
# the above change does not "stick" - the internal validation
# switches it back to .dbf
return
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
# I needed add this because the default validation
# was not finding existing data and warning me.
if self.params[1].value:
if arcpy.Exists(self.params[1].value):
self.params[1].setIDMessage("Error",1251)
returnNo clue, but perhaps it interprets != "Table" as being true if a shapefile is the input, is there anyway you can check to see whether a *.shp or shapefile or featureclass is checked rather than a table?
>>> arcpy.Describe("polygon_Diss").dataType
u'FeatureLayer'
>>> arcpy.Describe(r"D:\Users\cprice\work\polygon_Diss.shp").dataType
u'ShapeFile'