I have a block with an attribute called Local_height. This is a user input.
Below I have a text where I want to insert a calculation (Local_height + 748), this would be the Global Height.
I have inserted %<748+int(UserText(“block”,“Local_height”))>%.
It works unless the Local height has a decimal point.
See below. local height -3 works, whereas -5.5 does not compute.
I have the feeling I am missing something very obvious but I can’t see it.
Any ideas?, N
PS. Sorry, this is sort of a repeat post, but the first one did not get any replies.
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.
@jeremy5
Out of curiosity:
Do you have a “magic python” way of taking one of the coordinates of the block’s own insertion point instead of using the UserText?
i.e. something like the FAKECODE: 748+float(<PointCoordinate(“ThisBlockInsertion”,“Z”)>)
Cheers, N