We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
Sunday
I am creating an algorithm for graphically adding/subtracting elements of an array (dim_xy[ ][ ]) using hotspots (from the hot_mnu[ ] array).
It seems to me that adding new elements to the dim_xy[ ][ ] array works OK:
😊
But removing elements from the dim_xy[ ][ ] array unfortunately does not work properly because the last removed element of the array is restored:
😕😕😕
I noticed that for removing an element from the dim_xy[ ][ ] array to work, I have to click a hotspot not related to the hotspots hot_mnu[ ] before removing, i.e. remove in two stages:
😎😕
Where is the error? Can someone help?
I am attaching HotspotMenuGsm.zip (Ac27)
Solved! Go to Solution.
Tuesday - last edited Tuesday
the GLOB_MODPAR_NAME is the problem
when changing the value it thinks the script runs, but it runs this happens
step 1
step 2-remove point 3
step3 remove another point, i selected new point 4
because another parameter isn't actually modified, the script does not fully run (the parameter operation does not run and inject the values back to the library part parameters, only the temporary used variables are modified), and the ghost points stay.
this problem happens normally with editable hotspots, as you can edit parameters without going to the settings dialog box.
if you edit a variable other than the subtraction node then the script runs correctly (the parameters are injected back to the library part parameters) and the nodes are correctly set after this.
https://gdl.graphisoft.com/gdl-style-guide/script-type-dependent-recommendations
"Even if the user changed the parameter specified in an if GLOB_MODPAR_NAME
condition, the else branch will be evaluated"
this is what happens for the 2d output.
(but the parameter script commands are not evaluated for the instance where the parameter is not the subtraction parameter, so no update to library part parameters)
when you open the settings dialogue box, the parameters part of the script is run and then the ghost points are deleted, so everything appears to have worked.
A classic "Schrödinger's Cat"
the answer is quiet simple and elegant:
you just add a second add/subtract field, that you then evaluate on alternate loops
hot_mnu_1 and hot_mnu_2, so you can do the same without having to have the "Click again" value
and you set a variable toggle to switch between them in 2d, solves the problem of the "GLOB_MODPAR_NAME" not eqaul to....
...sorry, i was working on the original library part.
you could also just do a VALUES "hot_mnu" range[-total_count,100] so you could add up to 100 new objects
Tuesday
@AllanP, thanks for giving me hope back, although my language barrier and lack of experience with gdl make it difficult for me to understand your explanations and achieve my goal...😟
Tuesday
Do not worry, gaba. It is hard for me too to understand what experts suggest.
Anyway I got a good hint from AllanP:
"you just add a second add/subtract field, that you then evaluate on alternate loops"
I'm not sure if I understood it right but...
The idea is use two parameters ("add_remove" and "_add_remove" ) for producing new points and switch between them by "valve" parameter.
It works like 4 stroke combustion engine. When the "add_remove" parameter is working then the parameter "_add_remove" is resetting. Valve controls which parameter is in use.
So every time You have a clean parameter array to mark the edited point.
There must be a restriction for loops, we need to run this only once. Therefore next lines are added:
Tuesday
@AllanP and Pertti Paasky, Thank you very much for digging into the topic! 😉
quickly: before I just added hot_mnu2 and in the 2d script I drag hot_mnu and hot_mnu2 (and the user doesn't see the difference etc.), and in the code I compare the changes of hot_mnu with hot_mnu2... And something already works OK for me when adding new dim_xy elements.
I will soon decipher the removal of dim_xy elements, but ... Pertti Paasky, you anticipated my efforts ! I will soon test HotspotMenu_2!
I once practiced this mechanism of comparing the new and previous values in other library objects, but in a two-column table as abs(hot_mnu[1][1]-hot_mnu[1][2])>.001 and it worked for me in the object parameters window.
Hmmmm, instead of struggling with how to show dynamically created elements in the UI (prism etc..) 😬, it would be better to simply provide the user with basic functions in the project in the 2D/3D window (change material etc.) in the cursor context menu.
After all, hotspots could have some extra BIT (e.g. +2048, 4096... ) that would allow you to easily connect the cursor context menu with the VALUES{2,3,4...} options to the hotspot. Then there would be no need to drag the cursor to select the value 1,2,3...
Tuesday
Try VALUES{2}
You can connect text type array to integer array.
Tuesday
that's what I'll do eventually, and for now I have to switch my old way of understanding gdl to a new one after seeing e.g.:
n = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if isFirstRun then...
"A man learns his whole life and still dies stupid..."
Tuesday - last edited Tuesday
What a twist! 😃
@Pertti Paasky, I've slimmed down your code and I think it works OK.
1. I've integrated repeatable operations (when using "add_remove" or "_add_remove").
2. At the end I've added reset/update of the "add_remove" a nd "_add_remove" arrays when they're no longer used.
😊😉😄
Now I'll get down to connecting INTEGER Values{2}...
Tuesday - last edited yesterday
planned goal achieved ! 😃
1 - identification of a dragged hotspot
2 - sample menu of VALUES{2} options connected to the hotspots
(and I also switched the hotmenu tables REAL>INTEGER and changed the names of variables according to my own concept; while dragging hotspots you just have to be careful to "hit" the INTEGER values 1,2,3,-1,-5 etc, because this algorithm is more focused on using the hotmenu than regular dragging)
Thank you very much AllanP and Pertti Paasky for your interest in the subject and substantive help 😃
😃😃😃😃😃😃
────────────────────────
Edit:
for the sake of order and to finish the topic I am attaching the source object developed by Pertti in which it is easy to add new hotspots (drag to the right) and remove hotspots (drag to the left); this object operates with add_remove[] and _add_remove[] arrays and REAL values.