Search code examples
gdlarchicadgraphisoft

Graphisoft GDL - How to get layout name and number inside GDL object


I want to show the layout name and number inside a gdl object that I placed on my layout.

How can I get a layout name and number into my GDL script?


Solution

  • You can get the layout name in several ways inside your GDL script.

    A commonly used solution is to use the autotext tags <LAYOUTNAME> or <LAYOUTID> as a string. This tag will be replaced by the layout name or layout id AFTER the gdl object has compiled.

    xPos = 0;
    yPos = 0;
    TEXT2 xPos, yPos, '<LAYOUTNAME>'
    

    or

    TEXT2 xPos, yPos, '<LAYOUTID>'
    

    All autotext tags can be found here in the documentation.

    Note: Be aware that <LAYOUTID> and <LAYOUTNUMBER> are two different things!

    The problem with this solution is that you cannot use the value in for example function to compare with a value. So this will never evaluate to true:

    '<LAYOUTNAME>' = 'my layout name'
    

    In case you want to do something like that that there is an alternative way using the GDL REQUEST options function

    n = request ("HomeDB_info",  "", n, LayoutId, LayoutName, n)
    

    The values will be stored in the variables LayoutId and LayoutName

    This is also documented here and mentioned here on the ArchiCAD-TALK forum

    It is possible to evaluate this value and use this directly in your code:

    IF LayoutName = 'my layout name' THEN
        ! layout name is 'my layout name'
    ELSE
        ! layout name is something else
    ENDIF