Less complex examples

Home Forums About this site Ideas about GDL Center Less complex examples

This topic contains 6 replies, has 4 voices, and was last updated by  Laszlo Nagy 2 years, 2 months ago.

  • Author
    Posts
  • #1480

    Frank Studzinski
    Participant

    Great idea!
    I hope there will be more!
    (Reading XML files….)

    maybe you can build less complex examples. I’ve read “always readable text”,
    where are many parameters which are useful, but make it harder to understand.

    F.e. there are 3 Textstyles, but only one is used. For a real object it’s nice to have parameters to set the textstyle, but for an example they are IMHO confusing.

  • #1481

    Csilla Mai
    Keymaster

    Hi Frank,

    I have made some changes in the text handling examples, but we are not planning to reduce the complexity of the examples. The text handling examples in the Tips & Tricks category are based on the 15. Text handling learning tutorial, the How to display values with units set in Project Preferences? is based on the 16. Advanced Text Handling learning tutorial. I hope that reading these tutorials will make it easier to understand the Tips & Tricks sections.

    Csilla Mai
    Library Developer, Library Team
    GRAPHISOFT SE

  • #1482

    Frank Studzinski
    Participant

    It’s not the problem that i didn’t understand how to format a teststyle, but i would be easier to follow.

    To understand how you rotate the text, i first have to check in which line you handle the Rotation and in which not.

    Before i can run the script i have to create 10 parameters!

  • #1483

    Frank Studzinski
    Participant

    Maybe more like this:

    ! ——————————————————————————
    ! Input parameters controlled by the user:
    ! ——————————————————————————
    ! ZZYZX – (Length) height of the block whose data are displayed

    ! iTypeTextRotation – (Integer) type of the text rotation:
    ! 0 – Align with Symbol, 1 – Always Horizontal,
    ! 2 – Readable

    ! ——————————————————————————
    ! Draw the block in 2D
    ! ——————————————————————————
    rect2 0, 0, A, B

    ! ——————————————————————————
    ! Define styles
    ! ——————————————————————————

    define style “Style1” “Arial”, 2.5, 1, 0
    rrr=request(“Height_of_Style”,”Style1″,theight1)

    ! ——————————————————————————
    ! Text Rotation – Readable / Always Horizontal / Align with Symbol
    ! ——————————————————————————
    r = request (“View_Rotangle”, “”, _angleViewRot)

    ! Actual rotation of the 2D symbol:
    _totalRotate = (SYMB_ROTANGLE + _angleViewRot) MOD 360

    ! Count the number of transformations of the
    ! coordinate system in different cases

    _nTrans = 0

    if iTypeTextRotation = 2 then ! Readable
    if (_totalRotate > (90 + EPS) & _totalRotate < (270 + EPS)) then
    rot2 180
    _nTrans = _nTrans + 1
    endif
    else
    if iTypeTextRotation = 1 then ! Horizontal
    rot2 _totalRotate * (SYMB_MIRRORED – not(SYMB_MIRRORED))
    _nTrans = _nTrans + 1
    endif
    endif

    ! ——————————————————————————
    ! Set input data for the text drawing
    ! ——————————————————————————
    ! Set the multiplier of the paper scale
    PAPER_TO_MODEL = GLOB_SCALE / 1000
    ! Set text coordinate variable:
    ! samplesize is given in Paper Size – mm, convert it into Model size – m
    ! calculate the row height from it,
    ! therefore the row height will not depend on the font family
    dy = – theight1 * 1.5 * PAPER_TO_MODEL
    ! ——————————————————————————
    ! Display the texts
    ! ——————————————————————————
    style “Style1” ! Set the previously defined style
    text2 0, 0, “Text 1”
    text2 0, dy, “Text 2”
    text2 0, dy * 2, “Text 3”
    text2 0, dy * 3, “Text 4”

    ! ——————————————————————————
    ! Delete transformation after Text Rotation
    ! ——————————————————————————
    del _nTrans

  • #1494

    Gergely Fehér
    Keymaster

    Hi Frank,

    When writing sample codes, there are a lot of reasons for us to consider beyond simplicity. Instead using less lines in an example, we want to create codes in accordance with GRAPHISOFT’s coding style and standards, since these are important parts of learning scripting, too. Our goal is to have examples with a common base in related topics, and have each post adding a different function to it. We hope this could benefit the regular readers in longer terms. Tips&Tricks examples should be close to real use cases, meaning extra parameters and functions appear besides the example function itself.
    In the near future examples are going to be added as downloadable content to the posts (for your convenience:)), so there will be no need to create all parameters manually, you can go ahead and test the function right away in ARCHICAD.

    One recommendation: Learning pages and Tips&Tricks posts can be commented at the end of each article, so any related remark commented there is automatically linked to the post itself, making it easier for others to follow.

    Gergely Fehér
    Team Leader, Library Team
    GRAPHISOFT SE

  • #1498

    Frank Studzinski
    Participant

    Please don’t misunderstand my comment. It’s great to have first hand examples for GDL.
    My experience with my students,our clients and with my own brain, is that it’s hard to follow those complex scripts. It’s hard to focus on the problem, when i first have to filter which part of the script handles the problem and which is only additional.

    Maybe you can combine both methods.

    First you show the part of the script wher you handle the problem you want to explan.
    f.e.


    _totalRotate = (SYMB_ROTANGLE + _angleViewRot) MOD 360

    if iTypeTextRotation = 2 then ! Readable
    if (_totalRotate > (90 + EPS) & _totalRotate < (270 + EPS)) then
    rot2 180
    _nTrans = _nTrans + 1
    endif
    else
    if iTypeTextRotation = 1 then ! Horizontal
    rot2 _totalRotate * (SYMB_MIRRORED – not(SYMB_MIRRORED))
    _nTrans = _nTrans + 1
    endif
    endif

    and than you show the whole script.

  • #1509

    Laszlo Nagy
    Participant

    Maybe there should be both simple examples, and Graphisoft-compliant examples as well so both purposes would be achieved.

    Laszlo Nagy
    ARCHICAD-TALK Moderator, Site Admin

You must be logged in to reply to this topic.