I want to do multiple "calculate values" in ModelBuilder. To make it simple let´s take only 2 simple calculations: 1) calculate sine from angle to variable "MySinus" 2) use this value in a second calculation to calculate a hypothenuse in a triangle.
I want to keep the result of calculation 1) in a separate Variable "MySinus", so doing 1) and 2) in a single step is not an option (the real calculation i have to do is more complicated with 15 and more connected calculations plus geoprocessings)
It is clear, that calculation 1) must be done before calculation 2). I could use a precondition, but what if the result is a negative number? Then the 2nd calculation won´t be executed, because precondition is "false".
Calculation Value 1: Expresssion: math.sin(-math.pi*0.55)
Calculate Value 2: Expression: %abc%*5
What I tried already: - Calculation Value 1) data type to "variant" with result: Executing (Calculate Value 1): CalculateValue math.sin(-math.pi*0.55) # "Any value" Start Time: Mon Jan 12 11:39:10 2015 Value = -0,987688340595138 Succeeded at Mon Jan 12 11:39:10 2015 (Elapsed Time: 0,28 seconds) Executing (Calculate Value 2): CalculateValue -0,987688340595138*5 # Double Start Time: Mon Jan 12 11:39:10 2015 Value = Succeeded at Mon Jan 12 11:39:10 2015 (Elapsed Time: 0,05 seconds)
(Second Value isn´t really calculated !!!)
Calculation Value 1) data type double Result: Executing (Calculate Value 1): CalculateValue math.sin(-math.pi*0.55) # Double Start Time: Mon Jan 12 11:40:50 2015 Value = -0,987688340595138 Succeeded at Mon Jan 12 11:40:50 2015 (Elapsed Time: 0,05 seconds) Executing (Calculate Value 2): CalculateValue -0.987688340595138*5 # Double Start Time: Mon Jan 12 11:40:50 2015 The process did not execute because the precondition is false. Succeeded at Mon Jan 12 11:40:50 2015 (Elapsed Time: 0,00 seconds)
Change Expression in Calculation 2) to: float(%abc%)*5 Result: Executing (Calculate Value 2): CalculateValue float(-0,987688340595138)*5 # Double Start Time: Mon Jan 12 11:42:12 2015 ERROR 000539: Error running expression: float(-0,987688340595138)*5 Traceback (most recent call last): File "", line 1, in TypeError: float() takes at most 1 argument (2 given)
Failed to execute (Calculate Value 2). Failed at Mon Jan 12 11:42:12 2015 (Elapsed Time: 0,05 seconds)
(it seems that there is a problem with comma recognized as parameter delimiter)
- Change Expression in Calculation 2) to: float("%abc%".replace(",","."))*5
Executing (Calculate Value 1): CalculateValue math.sin(-math.pi*0.55) # Variant Start Time: Mon Jan 12 11:53:47 2015 Value = -0,987688340595138 Succeeded at Mon Jan 12 11:53:47 2015 (Elapsed Time: 0,07 seconds) Executing (Calculate Value 2): CalculateValue float("-0,987688340595138".replace(",","."))*5 # Double Start Time: Mon Jan 12 11:53:47 2015 Value = -4,93844170297569 Succeeded at Mon Jan 12 11:53:47 2015 (Elapsed Time: 0,05 seconds)
Finally !!!!!
Is there any simplier way instead of this there an back conversion?? (Of course I could use a python script for all this calculations, which seams to be straight way. But how to do it easy in ModelBuilder?)