GDL
About building parametric objects with GDL.
SOLVED!

Page Sizing Logic

Eric B
Enthusiast

Hi everyone

 

I am using the following code to determine the size of the page so I can show the page size along with the scale in our drawing title

 

 

sheetSize = "A1"

if AC_LayoutRect[3] < 841 then
	sheetSize = "A1"
endif

if AC_LayoutRect[3] < 594 then
	sheetSize = "A2"
endif

if AC_LayoutRect[3] < 420 then
	sheetSize = "A3"
endif

 

 

For some reason if the sheet size is A2 and AC_LayoutRect[3] = 562.5 the sheet size will still drop though all the if statements to the last if statement and set it to A3

 

Is there a specific way to read the value out of the array so that it can be used as a comparison be?

 

I cannot figure out why the last statement is reading true

 

Any help would be greatly appreicated

 

Cheers


Eric


AC6 till current
PC and Mac
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
MF BIM
Enthusiast

Hello @Eric B ,

 

The issue is simple, it's a unit problem. Your code checks values in meters and you thought it was checking them in millimeters.

 

In the GDL script, I always keep in mind that length values are in meters. I don't know if this can be changed somewhere but that's my rule when it comes to those. The reason the last condition is true, it's because an A2 sheet size is indeed inferior to 420 meters 😅

 

Have your constants in meters and this should work. Also, I would have nested ifs preferably, it looks cleaner and prevent unnecessary tests.

sheetSize = ""

if AC_LayoutRect[3] < 0.420 then
	sheetSize = "A3"
else
	if AC_LayoutRect[3] < 0.594 then
		sheetSize = "A2"
	else	
		sheetSize = "A1"    ! default
	endif
endif

 

https://mfbim.fr | https://youtube.com/@mfbim | https://bsky.app/profile/mfbim.fr
AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro

View solution in original post

8 REPLIES 8
Lingwisyer
Guru

Can you not just:

TEXT2 0, 0, AC_LayoutRect[3]

or does that not work for some weird odd reason?

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

That will output the right hand bottom corner of the sheet

 

I am trying to use that to create a crude switch statement so it will output A1, A2 or A3 as the sheet size


AC6 till current
PC and Mac

I mean so that you can see what it is returning since you said your output is coming up as A3 even though your sheet size is greater than 420. Print out the variables in question to check that they are returning the expected values.

Lingwisyer_0-1697083913405.png

I have a list of 47 different calculated variables in one of my objects that I have printed out at one point or another. Lots and lots of trig...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Apologies - yes I've done that

 

An A2 returns 562.5 which is why I am stumped as to why it still enters the third if statement


AC6 till current
PC and Mac
Eric B
Enthusiast

 I have looked into this further

 

If I just output the contents of AC_LayoutRect[3] of an A2 sheet of paper I get a value of 567.2

All the if statements will be evaluated but it will still enter the A3 if statement

 

If I change the coding and hard code the value 567.2 instead of AC_LayoutRect[3] then it goes as far as the A2 statement and will display the correct paper size

 

Is there something specific I should be doing to read this value or is there a specific place that this array is being populated and therefore I am trying to read it too soon? I am kind of at a loss as to why it won't run correctly

 

Cheers


Eric


AC6 till current
PC and Mac
Solution
MF BIM
Enthusiast

Hello @Eric B ,

 

The issue is simple, it's a unit problem. Your code checks values in meters and you thought it was checking them in millimeters.

 

In the GDL script, I always keep in mind that length values are in meters. I don't know if this can be changed somewhere but that's my rule when it comes to those. The reason the last condition is true, it's because an A2 sheet size is indeed inferior to 420 meters 😅

 

Have your constants in meters and this should work. Also, I would have nested ifs preferably, it looks cleaner and prevent unnecessary tests.

sheetSize = ""

if AC_LayoutRect[3] < 0.420 then
	sheetSize = "A3"
else
	if AC_LayoutRect[3] < 0.594 then
		sheetSize = "A2"
	else	
		sheetSize = "A1"    ! default
	endif
endif

 

https://mfbim.fr | https://youtube.com/@mfbim | https://bsky.app/profile/mfbim.fr
AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro
Eric B
Enthusiast

You are 100% correct

 

I have a mul2 to convert all the code to mm but it was after the if statements and of course because the array was storing the dimensions in mm I didn't give it another thought

 

Thanks for you help with this as I had been looking at the code trying to figure out what I had done wrong


AC6 till current
PC and Mac

Hi,

 

Parameters are never affected by transformations. Length parameters are always stored as meters - work environment has an effect on how they are shown on the UI, and you can use imperial numbers in code, but the parameter actual values will still be meters. Angles are always degrees.

 

Another thing to know is that the data is two diagonal points of the printable area (blue border) relative to the drawing title's coordinate system, plus the rotation of the drawing title relative to the layout. The length of one side has to be calculated from these.

Péter Baksa
Software Engineer, Library
Graphisoft SE, Budapest

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!