# -*- coding: utf-8 -*- ############################################################################ import sys # Import arcpy module import arcpy #from arcpy import env # Set this to False once testing is complete arcpy.env.overwriteOutput = True ############################################################################ # Script arguments # user defined weights for importance of up to three floral seasons Spring = float(arcpy.GetParameter(3)) arcpy.AddMessage("Floral Weight #1 is equal to: " + str(Spring)) if Spring == '#' or not Spring: Spring = 0.3 # provide a default value if unspecified check1 = arcpy.Parameter(Spring) arcpy.AddMessage("Data type is: " + str(check1.datatype)) Summer = float(arcpy.GetParameter(4)) if Summer == '#' or not Summer: Summer = 0.6 # provide a default value if unspecified Fall = float(arcpy.GetParameter(5)) if Fall == '#' or not Fall: Fall = 0.1 # provide a default value if unspecified Tot = Spring + Summer + Fall arcpy.AddMessage("Floral Weights are equal to: " + str(Tot)) if Tot == 1: arcpy.AddMessage("Sum of floral weights is equal to: " + str(Tot)) else: arcpy.AddError("The sum of floral weights must equal to one.") sys.exit() # exit out of model if weights don't add up to 1 ############################################################################
Solved! Go to Solution.
import arcpy a = arcpy.GetParameter(0) b = arcpy.GetParameter(1) c = arcpy.GetParameter(2) total = a + b + c arcpy.AddMessage(total) if total == 1.0: arcpy.AddMessage(" all good") else: arcpy.AddMessage(" all NOT good")
import arcpy a = arcpy.GetParameter(0) b = arcpy.GetParameter(1) c = arcpy.GetParameter(2) total = ((a * 100) + (b * 100) + (c * 100)) arcpy.AddMessage(total) if total == 100: arcpy.AddMessage(" all good") else: arcpy.AddMessage(" all NOT good")