GDL
About building parametric objects with GDL.
SOLVED!

How do I state GDL units?

henrybs14
Participant
Hi Guys

Slowly teaching myself the basics of GDL. But one thing that confuses me is object units default to meters.
So my 450mm chair is 450m, even though my project is set to mm


Is there a command for this? I tried searching the forum but had no luck.
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution
A_ Smith
Expert
Length in GDL is in meters. For examle, A=1 means A = 1m = 1000mm. So if you set A=450 its equal 450m=450 000 mm.
AC 22, 24 | Win 10

View solution in original post

Solution
Peter Baksa
Graphisoft
Graphisoft
If you are working with constants in the code, you can use multiplication.
INCH = 0.0254
MM = 0.001
M = 1
BLOCK 1 * INCH, 20 * MM, 3 * M

On the UI always use Length and Angle parameter types for lengths/angles, their representation change according to the workspace settings.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

View solution in original post

6 REPLIES 6
Solution
A_ Smith
Expert
Length in GDL is in meters. For examle, A=1 means A = 1m = 1000mm. So if you set A=450 its equal 450m=450 000 mm.
AC 22, 24 | Win 10
henrybs14
Participant
So how do most people deal with this issue?
Do they request the working units somehow? or do they run a loop through all their variables first to divide by 1000?

Or do most objects just become 0.45 instead of 450, since I see archicad objects work fine, pretty sure i can make 1012mm table too.
Karl Ottenstein
Moderator
It's not clear what you're trying to do that is causing difficulty. Typically, there is nothing to do... the fact that GDL interprets numeric lengths internally as meters isn't something that anyone usually needs to pay attention to.

For example, if your Working Units are meters and your parameter A is the chair dimension you want to be 450mm, then you would enter 0.45 for that parameter in the object settings dialog. If your Working Units are millimeters, you would enter 450. When the parameter is passed to the object script, the conversion is performed to meters. Same if an Imperial Units user entered 1'-6" in the object settings dialog (or in the script) ... that would be converted to meters if you were to examine the value received in the object script (0.4572 m).

If you are hard-coding your chair to be 450mm, then you would enter 0.45 in your script.

In case this isn't clear yet (I'm tired), let's say you have a parameter in your object that defaults to 450mm (so you would have entered it as 0.45 since values are meters inside your script). In the Object Setting dialog, if your working units are set to mm, that parameter will appear as 450. If you working units are meters, it will appear as 0.450.
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
runxel
Legend
One should mention that in the GDL editor's parameter list you can have two types, that look similar, but behave differently.
One is the length parameter, the other is the "natural number" parameter. Both are represented as floats, so it is not obvious in how they differ.
However, the natural number parameter will stay the same no matter the working unit; the length parameter on the other hand will itself present differently to the user – depending on what working unit is set.
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Solution
Peter Baksa
Graphisoft
Graphisoft
If you are working with constants in the code, you can use multiplication.
INCH = 0.0254
MM = 0.001
M = 1
BLOCK 1 * INCH, 20 * MM, 3 * M

On the UI always use Length and Angle parameter types for lengths/angles, their representation change according to the workspace settings.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

I totally forgot that only the default unit is metre, inch/feet can be used when specified:

block 1", 1', 1'-1"

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest