GDL
About building parametric objects with GDL.
SOLVED!

How to hange A & B values of object with an IF script?

Bilkins
Contributor

Hi,

This might be a simple question, but I've not been able to find anything that helps me.

 

What I would like is quite simple - make A and B have different preset values that can be toggled.

Say I want to make a rectangle, but I want it to have preset dimensions selectable from a list. In my head it should work like this, but it doesn't. Any suggestion would be welcome.

 

 

2D

Rect2 0,0,A,B

END
PARAMETERS:

VALUES "size" "min", "medium", "max"

IF "size" = "min" THEN
PARAMETERS A=2
PARAMETERS B=2*2
ENDIF


IF "size" = "medium" THEN
PARAMETERS A=3
PARAMETERS B=3*3
ENDIF


IF "size" = "max" THEN
PARAMETERS A=5
PARAMETERS B=5*5
ENDIF 

 

26.7004 NOR │ Win 11 Enterprise x64 ● Intel 9 185H @ 2.30GHz ● 64GB ● Nvidia RTX 3000 Ada
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

Sorry, I just copied & pasted your script.

 

Should be

IF size = "min" THEN
A=2
B=2*2
PARAMETERS A=A, B=B
ENDIF

 

Without the quotes around the size variable.

 

Barry

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

View solution in original post

Solution

And something like that ?:

 

VALUES "size" "min", "max"

LOCK "A", "B"

IF GLOB_MODPAR_NAME ="size" and size = "min" THEN
A=2
B=2*2
PARAMETERS A=A, B=B
ENDIF

IF GLOB_MODPAR_NAME ="size" and size = "max" THEN
A=5
B=5*5
PARAMETERS A=A, B=B
ENDIF
Archicad 27 - GDL - PYTHON

View solution in original post

8 REPLIES 8
Barry Kelly
Moderator

First I would ...

 

LOCK "A", "B"

 

So they can not be changed by the user.

Then in your parameter script you should always set the value of the parameter first and then set the actual parameter.

So ...

IF "size" = "min" THEN
A=2
B=2*2
PARAMETERS A=A, B=B
ENDIF

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Bilkins
Contributor

Hi Barry,

Thanks for the reply. That doesn't affect the A or B values, they are still 1000 like default.

26.7004 NOR │ Win 11 Enterprise x64 ● Intel 9 185H @ 2.30GHz ● 64GB ● Nvidia RTX 3000 Ada

Hi Barry,

I tested it too, but every rect2 is always 1.00/1.00 and not of the A and B size..... !?

With Lock "A" and "B"... doesn't matter..... 

 

Value_IF_ENDIF_00.png

 

Value_IF_ENDIF_01.png

 

Value_IF_ENDIF_02.png

 

Value_IF_ENDIF_03.png

 

 

ArchiCAD v6.5 - 28 (CHE Swiss Edition) - macOS / WIN (Switzerland / Schweiz)
Workstation office specs: mac OS sequoia 15.5, Apple M2 Max, 64 GB RAM
Solution

Sorry, I just copied & pasted your script.

 

Should be

IF size = "min" THEN
A=2
B=2*2
PARAMETERS A=A, B=B
ENDIF

 

Without the quotes around the size variable.

 

Barry

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Solution

And something like that ?:

 

VALUES "size" "min", "max"

LOCK "A", "B"

IF GLOB_MODPAR_NAME ="size" and size = "min" THEN
A=2
B=2*2
PARAMETERS A=A, B=B
ENDIF

IF GLOB_MODPAR_NAME ="size" and size = "max" THEN
A=5
B=5*5
PARAMETERS A=A, B=B
ENDIF
Archicad 27 - GDL - PYTHON
Lingwisyer
Guru

What does a VALUES{2} command do when used with A or B? I have never tried it with any of the 3 base dimensions. You could then have a dropdown that tells you your values for each option without needing to open the settings dialogue.

 

Ling.

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

Thanks for the reply to both you and @Barry Kelly !

Can't believe it was something as simple as unnecessary quote marks breaking the script, but I'll take heart that I at least was on the right track.

What's the added benefit of adding this to the script?

IF GLOB_MODPAR_NAME ="size" and size = "max" THEN

 

26.7004 NOR │ Win 11 Enterprise x64 ● Intel 9 185H @ 2.30GHz ● 64GB ● Nvidia RTX 3000 Ada

Good suggestion, that is actually more suitable for my intended use (parking space object with different A & B dimensions based on a variety of parameters).

 

This script works:

VALUES{2} "size" 2.0, "min", 
5.0, "max"

VALUES{2} "width" size*2, "minwidth",
size*5, "maxwidth"

LOCK "A", "B"

A=size
B=width
PARAMETERS A=A, B=B


But I would ideally like VALUES{2] for B to be governed by VALUES{2] of the A-dimension. I'm not sure if that is possible? I can't seem to find the right parameter types to use.

 

VALUES{2} "size" 2.0, "min", 
5.0, "max"

VALUES{2} "width" size*2, "minwidth",
size*5, "maxwidth"

LOCK "A", "B"

IF size= "max" THEN
width = "maxwidth"
ELSE
width = "minwidth"
ENDIF

A=size
B=width
PARAMETERS A=A, B=B

 

26.7004 NOR │ Win 11 Enterprise x64 ● Intel 9 185H @ 2.30GHz ● 64GB ● Nvidia RTX 3000 Ada