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

'Use of real types can result in precision problems'

Durval
Booster
When trying to edit, in AC9, an object created by AC7, I get the message on the title of this post when the 'Check Script' button is pressed. I haven't changed anything in the scripts yet.
The line where the warning points to have IF statements like these:
IF B=0 THEN ....
IF anyparameter<>0 THEN...
Despite the warnings, the object seems to work perfectly.
What 'real types' is AC talking about??
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
23 REPLIES 23
Anonymous
Not applicable
Would using MOD(parameter)=90 work?
Anonymous
Not applicable
To clarify my previous comments here...

I have often used conditional tests of angle values for a variety of purposes (for example, to get symbol texts to appear correctly - not upside down, etc.). I find that I can easily exclude conditions that extremely close to 0, 45, 90, etc. (within 1/100th of a degree) since this is never an intentional setting.

I started doing this in version 6 (or 6.5?) when I found that mirroring elements would result in symbol angles of 359.9994 (or there about).

It is often possible to exclude certain angle values as meaningless. For example, I have moulding and trim objects with adjustable hotspots for the miter angles. Since no trim will ever be mitered to an angle over 175° (90° being a square cut), I set it up so that the part automatically snaps to a self return as soon as this angle is exceeded.

Whether you need to be concerned about accuracy to 0.0001° depends, I suppose, on the circumstances, but I can't imagine any such condition myself.
Anonymous
Not applicable
HANIEL wrote:
Would using MOD(parameter)=90 work?
I believe you mean INT(value). MOD uses the form x MOD y and returns the remaining (fractional, decimal) value after dividing x by y.

The INT function will not work if the actual value is 89.99°, and a whole degree (from 90.0000 to 90.9999) is a pretty large range.
Anonymous
Not applicable
Won't it be great when macro's (as functions) work 'properly' and we can use;

if MyApprox(Angle, 90, AcceptableError)=TRUE then ...

Define Function "MyApprox" (variable, value, limit)
if ABS(value-variable) <= limit then TRUE
else FALSE

Balazs - where are you?

- Stuart
Durval
Booster
The "real types" are worse than I thought.
The warning is haunting me in A LOT of IFs that used to work perfectly in AC7.
I did some simple tests. It seems that any condition wich has an "=" or a "<>" sign in an IF-THEN statement makes the warning to come up.
Is it possible that we can not use such a basic code as "IF something = anything" without the annoying message anymore??
Please tell me I'm wrong...
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Karl Ottenstein
Moderator
Durval wrote:
The "real types" are worse than I thought.
The warning is haunting me in A LOT of IFs that used to work perfectly in AC7.
I did some simple tests. It seems that any condition wich has an "=" or a "<>" sign in an IF-THEN statement makes the warning to come up.
Is it possible that we can not use such a basic code as "IF something = anything" without the annoying message anymore??
Please tell me I'm wrong...
It should only happen if either of "something" and "anything" is a real (floating point) number. In fact, the warning should also occur for the <= and >= operators .... anything that includes an exact equality (or the exact inequality <>).

As we discussed earlier, this should be a warning that can be turned off: why don't you make it an official wish over at:
http://archicad-talk.graphisoft.com/viewforum.php?f=31
so we can all vote.


Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Durval
Booster
Ok, I'll write a wish/poll about this issue.
But before this, let's clarify the wish a bit.
Where is, in ArchiCAD 9, the equivalent to 'Options>Preferences>Imaging & Calculation>Interrupt with error messages' that was present in AC 7 and older?
I understand what we want is not exactly this. We don't want the option to turn off the actual error messages; just the warning messages, i.e., the messages pointing to issues that don't necessarily prevent the scripts from working correctly.
So, there's another wish embeded in this one: the error/warning messages should be divided in two groups: critical and not-critical, or something alike.
Is that correct?
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Durval
Booster
Ok, the wish is now official:
http://archicad-talk.graphisoft.com/viewtopic.php?t=4827
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Ralph Wessel
Mentor
Durval wrote:
The line where the warning points to have IF statements like these:
IF B=0 THEN ....
IF anyparameter<>0 THEN...
Despite the warnings, the object seems to work perfectly.
What 'real types' is AC talking about??
This warning is really very helpful, but the way AC communicates it is not. 'Real' types means floating point numbers, i.e. numbers with a fraction part like 3.14159...

If you type something like, "IF (x = 0) ..." where x is a real number, it will definitely do something undesirable in the future. Say you have a real parameter called 'x', and its value is displayed as '0'; yet it is quite possible for the expression (x = 0) to return FALSE. Why? Because 'x' is really 0.0001, but ArchiCAD will not display that level of precision. It knows the value is not zero, but displays 0 to the user. Worse still, trying to type '0' into the value still doesn't make it 0 - ArchiCAD doesn't realise that anything has changed and leaves it as 0.0001. This can be very frustrating for users who don't understand these issues.

I never type expressions like "IF (x = 0) ....". I use the technique Karl described - define a level of precision at the beginning of your script and use that throughout, e.g.
eps = 1e-5
IF (ABS(x) < eps) ...
I think a better wish would be for errors/warnings to be displayed in something like the report window rather than displaying them one by one in a modal dialog box. Ideally you would be able to double click on any warning/error in the list and it would take you to the offending line. That way you can disregard warnings if you want to, but the reminder is always there... you never know when it might spare you a lot of grief.
Ralph Wessel BArch
Anonymous
Not applicable
StuartJames wrote:
Won't it be great when macro's (as functions) work 'properly' and we can use;

if MyApprox(Angle, 90, AcceptableError)=TRUE then ...

Define Function "MyApprox" (variable, value, limit)
if ABS(value-variable) <= limit then TRUE
else FALSE

Balazs - where are you?

- Stuart
Stuart, i agree with you.
Let's take this example about text position (old GV's names to make short).

IF (W~ > 90 AND W~ <= 270) THEN ROT2 180 ELSE ROT2 0
Currently, this script works, with some weaks for limt values, and i understand now, why.
Thanks to all the programmers for their explanations.

According to the new rules, i should write, if i understand correctly
eps=0.0001
IF (ABS(W~ -90) > eps AND ABS(W~ -270) <= eps) THEN ROT2 180 ELSE ROT2 0
it does'nt work.

If i write
IF ((W~ -90) > eps AND (W~ -270) <= eps) THEN ROT2 180 ELSE ROT2 0
this statement works perfectly.

DEFINE STYLE "5" Arial, htex, 5, 0
STYLE "5"
TEXT2 0, 0, mytext

May be i need some explanations to understand better, but i have to say that this is not intuitive for non programmers.
I prefer a more understandable solution, as Stuart proposed.