Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Use of real types...

Dave Seabury
Advocate
I am writing a script for a roof truss. I have to test for three conditions at the heel. For one of the conditions I am testing for zero ie IF heel_height - bottom_cord_height - plumb_cut_topcord = 0 THEN............ but i keep getting a warning "use of real types can result in precision problems"

Is there a way to get around this warning? Is testing for zero what causes it?

Thanks in advance

David
AC 19-26 Windows 10 64 bit, Dell Prercision 7820, Xeon Silver 2414R ( 12 Cores), 64 GB Ram, Quadro RTX 4000 8GB
5 REPLIES 5
vistasp
Advisor
David, try:
IF heel_height - bottom_cord_height - plumb_cut_topcord < 0.0001 THEN...
A better option, especially if you're going to test this condition multiple times, would be:

Master Script:
EPS = 0.0001
2D/3D scripts:
IF heel_height - bottom_cord_height - plumb_cut_topcord < EPS THEN...
= v i s t a s p =
bT Square Peg
https://archicadstuff.blogspot.com
https://www.btsquarepeg.com
| AC 9-27 INT | Win11 | Ryzen 5700 | 32 GB | RTX 3050 |
Barry Kelly
Moderator
You might want to make this ... IF ABS(heel_height - bottom_cord_height - plumb_cut_topcord) < 0.0001 THEN...

Just in case you do have the situation where you might have a negative value.
Otherwise any negative value will be less than the tollerence and will trigger the condition.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
The other way is to change the value to string and check if the string ="0" (if the STR parameters set to put 1 character)

If the object has some predefined heights/lenghts/whatever it is kind of useful.

But if the only one thingy is checked - the mentioned before solutions are better.

Best Regards,
Piotr
Dave Seabury
Advocate
Piotr, Barry and Vistasp,

Thanks for the insight and suggestions, I will try these and see if i can get to run as i think it should.

Thanks

David
AC 19-26 Windows 10 64 bit, Dell Prercision 7820, Xeon Silver 2414R ( 12 Cores), 64 GB Ram, Quadro RTX 4000 8GB
Anonymous
Not applicable