SOLVED!
How to change parameters and keep dimensione of an object?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-07-29 06:45 PM
‎2015-07-29
06:45 PM
It draws two rectangles. The second rectangle is always the height of the first plus a constant 'gap'.
There is a parameter called 'method', whose value can be 1 ou 2.
If method = 1, the 'B' parameter will be the height of first rectangle (h1=B), so the second rectangle has a height of B+gap.
If method = 2, then ' B' should be the height of the second rectangle (h2=B), so h1=B-gap.
I don't want the heights change when method is changed. Instead, I want the 'B' is recalculated so that the heights remain the same.
For instance, method=1, so h1=B=1000 and h2=1500. When method is changed to 2, then h1 should remain =1000 and h2=1500, but B must change from 1000 to 1500.
I wrote these scripts:
!---- Master Script gap = 0.5 IF method = 1 THEN h1 = B h2 = B+gap ELSE h1 = B-gap h2 = B ENDIF !--- Parameter Script VALUES "method" 1, 2 IF GLOB_MODPAR_NAME = "method" THEN IF method = 1 THEN PARAMETERS B = B-gap ELSE PARAMETERS B = B+gap ENDIF ENDIF !--- 2D Script RECT2 0, 0, A, h1 ADD2 1, 0 RECT2 0, 0, A, h2 DEL 1
What happens is that 'gap' is added/subtracted TWICE every time I change 'method' (in my example, B goes from 1000 to 2000 instead of 1500 when method goes from 1 to 2).
So I changed the Parameter Script to this:
!--- Parameter Script VALUES "method" 1, 2 IF GLOB_MODPAR_NAME = "method" THEN IF method = 1 THEN PARAMETERS B = B-(gap/2) ELSE PARAMETERS B = B+(gap/2) ENDIF ENDIF
And the code works as expected. But in the real-life objects I intend to write, it won't be so easy to compensate this difference.
So the question is: why the code within 'IF GLOB_MODPAR_NAME....' is executed twice when I change the parameter only onceand how could I correct this misbehavior?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Accepted Solutions
Solution
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-07-31 01:37 AM
‎2015-07-31
01:37 AM
Hi Durval,
This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more. I had this exact problem last year and it's a simple solution. Here is the topic I started. It has a working object in my last reply. Essentially you need to insert the code below from Michael Rensing (Found in this topic) which only runs part of the script if it is the first time the script is being run.
This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more. I had this exact problem last year and it's a simple solution. Here is the topic I started. It has a working object in my last reply. Essentially you need to insert the code below from Michael Rensing (Found in this topic) which only runs part of the script if it is the first time the script is being run.
Michael wrote:
This should do it.
n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", isFirstRun) IF isFirstRun THEN A=A+1 ELSE A=A ENDIF
Lachlan Green | Wilson Architects | BIM Manager, Architect
Started on AC9 | Currently AC27 & AC28 | BIMCloud | GDL
Mac Studio (14,13) M2 Max, 64GB, 1TB SSD | MacOS 14.7
Started on AC9 | Currently AC27 & AC28 | BIMCloud | GDL
Mac Studio (14,13) M2 Max, 64GB, 1TB SSD | MacOS 14.7
3 REPLIES 3

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-07-29 06:49 PM
‎2015-07-29
06:49 PM
The object is attached.
Solution
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-07-31 01:37 AM
‎2015-07-31
01:37 AM
Hi Durval,
This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more. I had this exact problem last year and it's a simple solution. Here is the topic I started. It has a working object in my last reply. Essentially you need to insert the code below from Michael Rensing (Found in this topic) which only runs part of the script if it is the first time the script is being run.
This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more. I had this exact problem last year and it's a simple solution. Here is the topic I started. It has a working object in my last reply. Essentially you need to insert the code below from Michael Rensing (Found in this topic) which only runs part of the script if it is the first time the script is being run.
Michael wrote:
This should do it.
n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", isFirstRun) IF isFirstRun THEN A=A+1 ELSE A=A ENDIF
Lachlan Green | Wilson Architects | BIM Manager, Architect
Started on AC9 | Currently AC27 & AC28 | BIMCloud | GDL
Mac Studio (14,13) M2 Max, 64GB, 1TB SSD | MacOS 14.7
Started on AC9 | Currently AC27 & AC28 | BIMCloud | GDL
Mac Studio (14,13) M2 Max, 64GB, 1TB SSD | MacOS 14.7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-08-21 09:00 AM
‎2015-08-21
09:00 AM
Create 2 new Parameters:
h = 1000
gap = 500
---------------------------------
h1 = h
h2 = h+gap
IF method=1 THEN
PARAMETERS B=h1
ELSE
PARAMETERS B=h2
ENDIF
h = 1000
gap = 500
---------------------------------
h1 = h
h2 = h+gap
IF method=1 THEN
PARAMETERS B=h1
ELSE
PARAMETERS B=h2
ENDIF
Howard Phua
Win 10, Archicad 19 INT
Win 10, Archicad 19 INT