Problem

We want to print a dimension string with rounded digits in style of German DIN 1356.

Solution

There are two solutions for different ArchiCADs and with different effort. The older one is the correct one. The newer is easier to handle in GDL. This older script was rewritten for common use for a question in the German GDL user forum.

Additional there is a explanation for usage with the quantity_text_writer - makro, which is part of the main library.

Script - ArchiCAD 8.0

var=1.2345 ! Example value for output

! Define styles and alignments
pos=9 ! Text style Ancor / alignment
posZ=INT((pos-1)/3)+1  ! Ancor row (1-3)
posS=pos-(posZ-1)*3    ! Ancor column (1-3)

fontH=2.5
DEFINE STYLE "dim_base" "Arial",fontH,pos,0
DEFINE STYLE "dim_expo" "Arial",
fontH*0.7,(posZ-1)*3+1,0

! Factor to find end of dimension base string (0, 0.5, 1)
pos=1-(posS-1)/2

! Request format settings
format = ""
dimension="LINEAR_DIMENSION"
sts = REQUEST (dimension, "",format)

! transfer value to string
var_base = str{2}(format,var,var_expo)

! output base
SET STYLE "
dim_base"
text2 0,0,
var_base

! Calculate base string dimension
baseW=STW(var_base)*GLOB_SCALE/1000
baseH=
fontH*GLOB_SCALE/1000*0.5

! output exponent
SET STYLE "
dim_expo"
text2
pos*baseW,baseH,var_expo

Script - ArchiCAD 9.0+

var=1.2345 ! Example value for output

! Request format settings
format = ""
dimension="LINEAR_DIMENSION"
sts = REQUEST (dimension, "",format)

! Check, if last digit is rounded
pos=STRSTR(format,"*")
IF pos THEN
  sts=SPLIT(STRSUB(format,pos+1,1),"%n",formR)
  formR=2-INT(FRA(formR/2)+0.5)
  ! Replace with corresponding rounding info *5 or *6
  format=STRSUB(format,1,pos-1) \
        +"*"+STR(4+formR,1,0) \
        +STRSUB(format, pos+2,255)
  ! Increase number of digits by 1 or 2
  pos=STRSTR(format,".")
  IF pos THEN
    sts=SPLIT(STRSUB(format,pos+1,1),"%n",digit)
    format=STRSUB(format,1,pos) \
          +STR(digit+formR,1,0) \
          +STRSUB(format, pos+2,255)
    ENDIF
  ENDIF

! output
varS = str{2}(format,var)

text2 0,0,varS

Script - ArchiCAD 11+

CALL "quantity_text_writer" PARAMETERS lengthValue = wert,
    !  0: Individuell (-> custom_form)
    !  1: "Linear_dimension"
    !  2: "Angular_dimension"
    !  3: "Angular_length_dimension"
    !  4: "Radial_dimension"
    !  5: "Level_dimension"
    !  6: "Elevation_dimension"
    !  7: "Window_door_dimension"
    !  8: "Sill_height_dimension"
    !  9: "Area_dimension"
    ! 10: "Calc_length_unit"
    ! 11: "Calc_area_unit"
    ! 12: "Calc_volume_unit"
    ! 13: "Calc_angle_unit"

    iUnitType = 5, custom_form="",
    ! Drehung: 1: Standard, 2: Standard + 90°, 3: Horizontal, 4: Vertikal
    GS_iMarkerDir = 1,
    ! Ausrichtung: 1: links, 2:mittig, 3: rechts, 4: "IntegerPart" /
    !              1: unten, 2: oben

    horizontalAlignment = 1, verticalAlignment=1,
    ! Drehung für Lesbarkeit an=1 oder aus=0, Vertikale Grenze für Lesbarkeit
    AC_Readable=0, gs_readable_angle=90,
    ! Schriftart
    AC_TextFont = Zeichensatz, AC_TextSize = SH, AC_TextStyle = schriftstil,
    ! Präfixtext
    szPrefix = "",
    ! Zeilenabstand und Unterlängen berücksichtigen
    useLeadingAndDescent = 1,
    ! Text berechnen=0 / ausgeben=1
    bShowText = 0,
    ! Mit=1 / Ohne=0 Einheiten ausgeben
    bShowUnit = 0,
    ! Rückgabewerte:
    RETURNED_PARAMETERS gesamtL, gesamtH, exponent
Um unsere Webseite für Sie optimal zu gestalten und fortlaufend verbessern zu können, verwenden wir nur essenzielle Cookies.
Durch die weitere Nutzung der Webseite stimmen Sie der Verwendung von Cookies zu.
Weitere Informationen zu Cookies erhalten Sie in unserer Datenschutzerklärung