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

extra_accuracy_string in STR{2}

Frank Beister
Moderator
Can anyone explain how does the thing with
STR{2}(format_string, numeric_expression [, exrta_accuracy_string])
work? What values for extra_accuracy_string are allowed?

REQUEST("Linear_dimension" ... returns "%#*1.3m" as formatstring. OK. A star for accuracy, but how to go on?

bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
3 REPLIES 3
gerd
Participant
zahl = 12345.4329
tx   = STR ("%#*3 1.2m", zahl) + "m"
TEXT2 0, 0, tx
this causes no error message in the gdl scripts, but the rounding of the number is not made.
no idea why.

this may gives us an idea, whats going round in the head of the gdl while 2d plan view is created (???)
zahl = 12345.4329
tx   = STR{2} ("%#*2 1.2m", zahl, abc) + "m"
TEXT2 0, 0, tx
print abc
maybe someone knows more?
best regards, gerd
Frank Beister
Moderator
Thanks to Gerd and Jochen, who brought me on track.

I thought the extra_accuracy_string would be an additional format string, but it is a return (!) string. It returns the exponent, which has to be printed after the return value of the function. To return anything inside the format string it has to be 'told' to the STR{2} function, that it has to calculate the exponent and the intervals for this. Is there no exponent, because it's zero, the value is an empty string. The 'exponent# is no real exponent, it is the rounded part after (!) the last decimal places, which is changed to string.

For this the format string has the configuration:

"%[flags][accuracy][min._#_of_chars][.decimal_places][conversion_unit]"

And [accuracy] can be "*0", "*1", "*2", "*3" and "*4". See manual.

e.g. "%+-*16.1m" means

% Beginning of string
+ Show always algebraic sign
- bounded to left margin (add spaces to the end)
*1 Accuracy format
6 Min. Number of chars: 6
.1 one digit after decimal point
m unit: meters

Mention, that "...*16..." can/has to be set without spaces, because the accuracy format is two chars wide. I think for this the star is part of this flag.

Puhhh. Hard work with the good old manual.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Hi Frank,
parallel to you I worked on this problem too, because at the moment I need accuracy for some values in my GDL Script. And have created one demo file according your post and Gerd's reply. You are right it was hard

P.S. I don't know how well you have solved your own question, but if find something wrong in demo, please reply!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!