Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I state GDL units?

henrybs14
Newcomer
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

Solution
A_ Smith
Contributor
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

5 REPLIES 5

Solution
A_ Smith
Contributor
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

henrybs14
Newcomer
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 25 USA and earlier   •   MacOS 11.6.1, iMac Pro

runxel
Mentor
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.
AC 24 [ger] | Win 10 | 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

View solution in original post

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!