The Magic Bit 1024
Handling dynamic Hotspots in GDL is one of the core experiences – after all this is as close to real-time parametricism as you can get in Archicad.
Hotspots bound to parameters allow the user to modify the current object without any need for a model dialog.
While the way how usual dynamic Hotspots are scripted is more or less trivial, albeit in a bit verbose way, there is one feature that is less prominent and even less documented but nonetheless indispensable when dealing with paper space.
As a quick recap, all lengths in GDL are measured in meter, which is called the model space. E.g., a wall with one meter in length.
The opposite of that is the so-called paper length, quintessentially named after the fact it is defined in paper space.
The best example is text sizes, with the height being set in millimeters.
In other words, a length specified as model length will stay the same in the model space, but on paper the representation is dependent on the view and its scale (like 1:100) The wall of 1.0 m in length, or 100 cm, will be displayed as 1 cm long in a view of 1:100 when placed on a layout / or subsequently printed. Just in case you forgot how scales work., while a paper length will change its size in the model viewport based on the current scale, leading to constant size on the layout / print.
Some objects might require parameters that represent a paper length instead of a model length. The issue of displaying that correctly while in a model viewport can be dealt with swiftly by juggling with the GLOB_SCALE global and elementary school arithmetics. However, the question arises when you want to be able to use Hotspots with a parameter representing a paper length.
This is when the magic 1024 bit comes into play. Magic, because the proper usage and needed pre-configuration needed is neither obvious, nor intuitive. It is also the only time, when the actual movable hotspot position variable, the value that ought to be modified, and the value to display differ from each other.
In the most simple Hotspot setup it is straightforward with three separate hotspot commands bound to a parameter by their status, signaling their functions: You have the base hotspot (status=1), which determines the point from where the subsequent length should be measured from.
Secondly, there is the movable hotspot. Usually that entails the very parameter that is being changed graphically.
And lastly, the point with status=3 that yields the inverted eigenvectorThe eigenvalue is not taken into account and does not matter. (P1→P3), meaning the direction opposite of the positive range of the modified parameter.
unID = 1
hotspot2 0, 0, unID, A, 1 : unID=unID+1 !base
hotspot2 A, 0, unID, A, 2 : unID=unID+1 !move
hotspot2 -1, 0, unID, A, 3 : unID=unID+1 !direction
As a recap, here's the usual Hotspot setup – nothing surprising here. In newer Archicad versions, the ID numbers are mandatory and, in a way, enforced: if not present they can not be captured by dimensions (at least in sections). The IDs need to be unique but have no other requirements. They do not even need to be sequential.
Omitted from the example is the optional "displayParam". Here it would be implicitly set to be "A" as well.
Some of these hotspots can be enhanced with different status bits added, telling Archicad how to further process the data or if it should hide or show different parts. One often used combination is bit 128 which will hide the base point (no hotspot shown while the object is selected).
Back to our hypothetical object trying to display a paper length with an accompanying Hotspot.
Some preparation is needed: Because this technique needs "parameter shadowing" we need to create two parameters. Both represent the same thing, but one will hold the value in model length, while the other holds the paper length. Since the latter is usually given in millimeters, I tend to reuse the parameter name by just suffixing it with "_mm".
Now let's tie them together in the Master / Parameter script:
!--- Master/Param script ---!
if GLOB_MODPAR_NAME = "A" then parameters A_mm = A*1000
if GLOB_MODPAR_NAME = "A_mm" then parameters A = A_mm/1000
Notice that there is no "GLOB_SCALE" involved yet – it is banned from being used in the Master / Parameter script because it is view dependent.
Let's head to the 2D script:
!--- 2D script ---!
_A = A * GLOB_SCALE
unID = 1
hotspot2 0, 0, unID : unID=unID+1
hotspot2 0, 0, unID, A, 1+128+1024, A_mm : unID=unID+1
hotspot2 _A, 0, unID, A, 2, A_mm : unID=unID+1
hotspot2 -1, 0, unID, A, 3, A_mm : unID=unID+1
line2 0, 0, _A, 0
... and that concludes the magic trick.
Why does this work?
The parameter A_mm will always hold a value in millimeters. But we need to work with real dimensions in GDL, so we cannot use it: We need the value in meters, which is obviously n meter times 1000, done in the Master script, where we sync both values. Then it does not matter what the user changes (and in which interface), the other value will always be correct.
The 1024-bit always only operates on the "paramReference" (word after the unID). Again, we can only use model space in GDL commands, so there is no chance to substitute it here with A_mm. Also, there is no flag to reverse from millimeter to meter, only the other way around.
You obviously Yes, we could do without the A_mm parameter – the 1024 would still work. However, in that case, the user will be shown nonsense in the pet palette. want to show the user the value in millimeters and enable them to put in a value in paper length as well. That's why we use the A_mm as the "displayParam".
And lastly because the 1024 only does its magic by scaling the distance of the editable hotspot to view scale when the Hotspot is in active use, we need to manually go from "A" to "_A" by multiplying it with GLOB_SCALE and putting it in as the position for the hotspot (and whatever geometry is created with it).
Certainly not the easiest thing to wrap your head around, and while it might seem to look like magic, even for some seasoned veterans, now you know you to handle the difference between model space and paper space in GDL.
