We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.
SOLVED!

Changing parameter independently using GLOB_MODPAR_NAME

Mario Sacco
Expert

This is only a simplified example.

I need modify a second parameter if a first parameter changes.

 

I  used this code:

 

IF GLOB_MODPAR_NAME = "k" THEN
PARAMETERS a = a*2
ENDIF

 

to create a simple rectangle

 

RECT2 0,0,a,b

 

The problem comes when I make changes on multiple objects. 

The Parameter "A" of the last object selected will be applied to all the objects.

I checked "Run the parameter script only once"

 

I'd like to have the parameter "A" modified independently.

 

Attached the example object.

 

 

MacBook M1 Max 64GB- OS X 12.2.1 - Archicad 27
https://www.archiradar.it/en/
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution
Barry Kelly
Moderator

Firstly you should probably script it like this.

 

IF GLOB_MODPAR_NAME = "k" THEN 
	a = a*2
	PARAMETERS a = a
ENDIF

 

 

a = a*2 will change the value of 'a' used in the scripts.

PARAMETERS a = a*2 will change the value of the parameter in the parameter list, but not necessarily the value of 'a' in the scripts, until the scripts are run again and they get the new value from the parameter list.

I don't quite understand it all but it is a good practice to follow.

The scripts are all run multiple times and setting the parameter script to run only once will have no impact on this.

 

 

Not that it will make a difference to what you want to do.

As you have multiple objects selected, even with different 'a' values, your script is telling it to change the 'a' parameter by doubling it.

Because they are all selected together, they will all change to the same 'a' value as the object settings that you are changing - as if you typed in the value for 'a' yourself.

 

This works fine when you have only one object selected.

But when you have multiple, you are effectively re-setting them all to the same 'a' value.

 

I am not quite sure how you would get around this.

 

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
DGSketcher
Legend

The logic is quite simple. A or any other parameter cannot be independently set in each object in a multiple selection. Changing a Parameter either directly or by script will be set to the same value across all selected objects.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)

View solution in original post

4 REPLIES 4
Solution
Barry Kelly
Moderator

Firstly you should probably script it like this.

 

IF GLOB_MODPAR_NAME = "k" THEN 
	a = a*2
	PARAMETERS a = a
ENDIF

 

 

a = a*2 will change the value of 'a' used in the scripts.

PARAMETERS a = a*2 will change the value of the parameter in the parameter list, but not necessarily the value of 'a' in the scripts, until the scripts are run again and they get the new value from the parameter list.

I don't quite understand it all but it is a good practice to follow.

The scripts are all run multiple times and setting the parameter script to run only once will have no impact on this.

 

 

Not that it will make a difference to what you want to do.

As you have multiple objects selected, even with different 'a' values, your script is telling it to change the 'a' parameter by doubling it.

Because they are all selected together, they will all change to the same 'a' value as the object settings that you are changing - as if you typed in the value for 'a' yourself.

 

This works fine when you have only one object selected.

But when you have multiple, you are effectively re-setting them all to the same 'a' value.

 

I am not quite sure how you would get around this.

 

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
Lingwisyer
Guru

Given that you are not using an IF statement after, would this not end up inconsistant as even if you select the parameter, then use the same input, it will double...?

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
Solution
DGSketcher
Legend

The logic is quite simple. A or any other parameter cannot be independently set in each object in a multiple selection. Changing a Parameter either directly or by script will be set to the same value across all selected objects.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)
Mario Sacco
Expert

Thank you @DGSketcher 

I understood the logic of these behavior.

I solved creating independent parameters.

MacBook M1 Max 64GB- OS X 12.2.1 - Archicad 27
https://www.archiradar.it/en/