Rounding length in feet to next greater value
Question:
In my template, how can I round up the length in feet to the next greater value? For example 18'-2" should be rounded up to 19'-0". I tried the function ceil, but it does not do what I expected. I want to format the result so that it displays the zero inches, like 19'-0".
Answer:
In templates, internal calculations are done in metrics. Only the result value is converted to imperial units. Therefore, ceil does not work directly for imperial units. Instead, select Data type = Text and use this formula:
int(ceil(GetValue("LENGTH")/25.4/12)) + "'-0\""
where
GetValue("LENGTH") gets the length in millimeters,/25.4/12 calculates the feet from the value,ceil rounds the value up,int converts the value to integer (cuts decimals off), and+ "'-0\"" adds the requested formatting.