cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Developer forum
GDL coding questions, Python and add-on development using the API Dev Kit.

Changing parameter independently using GLOB_MODPAR_NAME

Mario Sacco
Advocate

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 25
https://www.archiradar.it/en/
2 ACCEPTED SOLUTIONS
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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

Lingwisyer
Hero

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
Win10 | R5 2600 | 16GB | GTX1660 

Solution
DGSketcher
Champion

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 macOS Ventura / AC26UKI (most recent builds)

Mario Sacco
Advocate

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 25
https://www.archiradar.it/en/

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!