Calculation does not work with decimal

Yes you can. This is what your %<748+float(UserText(“block”,“Local_height”))>% would need to look like to format to two decimal places:

%<'{:#.2f}'.format(748+float(UserText(“block”,“Local_height”)))>%

For a different number of decimals just change the 2 to whatever you want.

What we are doing here is using Python formatting commands to display a string with a placeholder - the curly brackets - in it which will be filled with the result of the calculation in the brackets after the format instruction. You can also put boilerplate text in the string if you want, e.g.

%<'Global Ht: {:#.2f}'.format(748+float(UserText(“block”,“Local_height”)))>%,
however that is less relevant in Rhino fields because you can build the string outside the <> anyway.

HTH
Jeremy

1 Like