BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

GDL
About building parametric objects with GDL.
SOLVED!

GDL: Button Interaction

Lingwisyer
Guru

Hi all,

 

Anyone have a clue why this button is not inversing the values, but instead is making them uniform?

 

If the first entry is 1, I want all the entries to change to 0, and if it is 0 I want them all to become 1. Instead, it makes all the entries match the first...

 

 

IF GLOB_UI_BUTTON_ID = 3 then
	IF sg_lengthToggle[1][2] = 0 then
			FOR i = 1 to sg_noBasement
				sg_lengthToggle[i][2] = 1
				PARAMETERS sg_lengthToggle[i][2] = sg_lengthToggle[i][2]
			next i
		ELSE
			FOR i = 1 to sg_noBasement
				sg_lengthToggle[i][2] = 0
				PARAMETERS sg_lengthToggle[i][2] = sg_lengthToggle[i][2]
			next i
	endIF
endIF

 

 

 

 

Ling

 

https://community.graphisoft.com/t5/Document-Visualize-forum/Level-Marking-in-Section-and-Elevation-...

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
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Peter Baksa
Graphisoft
Graphisoft

Either you have to set "Run parameter script only once" in Compatibility Options, or query whether the script is run first after a user interaction:

 

isFirstRun = 0
success = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if success & isFirstRun & GLOB_UI_BUTTON_ID = ...

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

View solution in original post

8 REPLIES 8
DGSketcher
Legend

Is it a rerun problem? It looks to me that every time the code is run it will toggle the value. Should it perhaps be controlled using GLOB_MODPAR_NAME with the GLOB_UI_BUTTON_ID parameter?

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

It should only be running once on button press, unless GLOB_UI_BUTTON_ID does not reset after function? You cannot seem to use GLOB_UI_BUTTON_ID with GLOB_MODPAR_NAME. Not sure how else to enforce a single run if that is the cause...

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
A_ Smith
Expert

Maybe try changing to

PARAMETERS sg_lengthToggle = sg_lengthToggle ?

 

edit: plus i suggest to move PARAMETERS before last ENDIF, not to do it inside a loop

AC 22, 24 | Win 10
MetalFingerz
Advocate

@Lingwisyer ,

 

I managed to make it work by using a checkbox rather than a UI_BUTTON

 

test = sg_lengthToggle[1][2]
if invert then
        for i = 1 to sg_noBasement
                sg_lengthToggle[i][2] = not(test)
        next i
        parameters invert = 0
endif
parameters sg_lengthToggle = sg_lengthToggle

 

'invert' being the name of the checkbox. So if there is no necessity to use a button then you could juste stylize the checkbox like a button and that would work.

 

Solution
Peter Baksa
Graphisoft
Graphisoft

Either you have to set "Run parameter script only once" in Compatibility Options, or query whether the script is run first after a user interaction:

 

isFirstRun = 0
success = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if success & isFirstRun & GLOB_UI_BUTTON_ID = ...

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Lingwisyer
Guru

Put all my button queries between an IF statement of the first run query and it all works. Thanks again Peter.

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

@Peter Baksa , can you only have one first run query? I added a second one in my Master Script in order to offset array values, but it appears to break my buttons in my parameter script...

 

 

Ling.

 

ps. Would appear to be so, or at least that I can't do it in both the Master and Parameter scripts at the same time. Merged my Master one into my Parameter one.

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
Peter Baksa
Graphisoft
Graphisoft

The master script runs before the UI script too, and the query doesn't make sense in UI context - that is my first idea.

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Learn and get certified!