We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2017-06-30 11:28 AM
2017-06-30 11:47 AM
2017-06-30 01:09 PM
JGoode wrote:It's warning you that this code might do puzzling and unexpected things. Precision is critical when you are dealing with real numbers. Consider what happens if your variables have the following values:
I want to get rid of an error for this bit of code;
if (right_rail = left_rail) then
A = right_rail+0.2
endif
if (right_rail = left_rail…the result is false, because the values are different.
2017-06-30 01:30 PM
Ralph wrote:I also have the code;JGoode wrote:It's warning you that this code might do puzzling and unexpected things. Precision is critical when you are dealing with real numbers. Consider what happens if your variables have the following values:
I want to get rid of an error for this bit of code;
if (right_rail = left_rail) then
A = right_rail+0.2
endif
right_rail = 0.03001
left_rail = 0.02999
If you look at those values in a field or output as text, both will display as 0.03m (or 30.0mm). ARCHICAD will only display to the nearest 10th of a millimetre, so any digits beyond that threshold are rounded. But when a script like this runs:if (right_rail = left_rail…the result is false, because the values are different.
Rather than comparing them exactly, check that the difference between them is negligable, i.e. below a level of precision that makes a difference. That's what Piotr's example shows, assuming your level of precision is 0.1mm
2017-06-30 01:34 PM
JGoode wrote:Are you looking for something like:
I also have the code;
if (left_rail > right_rail) then
A = left_rail+0.2
endif
if (right_rail > left_rail) then
A = right_rail+0.2
endif
A = max(left_rail, right_rail) + 0.2
2017-06-30 01:37 PM
Ralph wrote:I seem to have got it not showing the error now with the following;JGoode wrote:Are you looking for something like:
I also have the code;
if (left_rail > right_rail) then
A = left_rail+0.2
endif
if (right_rail > left_rail) then
A = right_rail+0.2
endifA = max(left_rail, right_rail) + 0.2
A = max(left_rail, right_rail) + 0.2will do? I haven't seen anything similar to this thus far.
2017-06-30 01:47 PM
JGoode wrote:
Care to expand on what :A = max(left_rail, right_rail) + 0.2will do? I haven't seen anything similar to this thus far.