Example files for this lesson can be downloaded here.
How to get information from the project, the ARCHICAD environment? Some objects need to get information in order to work properly:
- scale sensitive objects
- objects connected or placed into a wall
- story sensitive objects
- objects using Model View Options
…and so on, depending on the function of your library part.
To get this information, GDL has 4 ways:
- global variables
- application queries
- fix named optional parameters
A special type of information channel are the autotexts: these are only evaluated right before displaying them, so it’s not possible to use the auto text value in a conditional statement, neither to calculate its size on the plan. They are eligible for display only. The most used ones can be found in the AUTOTEXT Guide of the GDL Reference Guide.
As mentioned before, GDL has 2 types of variables: one type is created and managed by the user, the other is created and managed by ARCHICAD itself. The latter type is called a Global Variable, and contains important and frequently used values about the environment in ARCHICAD.
The name is fixed, usually used with full capitals in scripts.
In the case of a “normal” global variable, the value is set and updated if necessary by ARCHICAD according to the context, project, current environment or the object type it can be used in. Basically, they can and should be used as a normal variable, except no need to initialize them (, ever).
On the other hand, there are some free global variables called user globals. The value of these variables can be set by the user globally.
Global variables are always available, set before the run of any script, and are accessible automatically in macros (if the caller object has access) as well. The value of the variable in the macro is usually the same as in the caller object (unless the variable is a special one to show difference when used in macro).
Global variables are arranged in groups depending on the area of usage. View or project dependent global variables should not be used in parameter scripts (or master scripts run as parameter script).
Example: the current scale of the floor plan is available via the GLOB_SCALE variable.
For the complete list of them, check out the Global Variables section of the GDL Reference Guide
Special, less frequently used global values can be accessed by using request functions in your scripts. These values are only invoked by the program if being directly asked for. A request is usually a strictly formalized statement, and the received information/value can be stored in a simple variable of the script (and used as such). Sometimes the mere success of a request is the demanded information itself.
Requests are not meant to be used in parameter scripts (or master scripts run as parameter script): returned values can be unstable, therefore should be avoided.
Example for request use case: story information of the project (story number, individual heights, etc.).
To see all options and examples, read on in the Request Options section of the GDL Reference Guide.
Very similar to requests, providing even more remotely used information about the environment. The return value is subject to change according to different circumstances. Formalized function, returned value can be stored in a normal variable. Not supported in parameter scripts.
Example use cases: MEP information, custom loaded image value list, Tags and Categories data structure, etc.
Full list of active application queries can be found in the GDL Reference Guide.
Fix Named Optional Parameters
Some parameters with a predefined name and type can open an information channel between ARCHICAD and your object. The direction of the information flow depends on the parameter’s function: push out information, receive information, or work both ways. It is defined as a regular parameter in your object, and has jurisdiction over the placed instance only. Only placeable objects get the automatic channel function once the parameter is created. To use the value in a macro, it has to be passed down manually from the caller object.
ARCHICAD refreshes the parameter value on the receiving end every time it is changed on the sender side.
Example use case: a placed instance of a door can determine the wall cross-section geometry type in “ac_wall_crosssection_type” parameter.
For the most commonly used names and functions, check out the Fix Named Optional Parameters in the GDL Reference Guide.