GDL
About building parametric objects with GDL.
SOLVED!

Array & hotspots menu

gaba
Enthusiast

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:

HotspotMenu1.gif😊

 

 

But removing elements from the dim_xy[ ][ ] array unfortunately does not work properly because the last removed element of the array is restored:

HotspotMenu2.gif😕😕😕

 

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:

HotspotMenu3.gif😎😕

Where is the error? Can someone help?
I am attaching HotspotMenuGsm.zip (Ac27)

 

"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080
17 REPLIES 17

the GLOB_MODPAR_NAME is the problem

 

AllanP_1-1732579107380.png

when changing the value it thinks the script runs, but it runs this happens

 

step 1

AllanP_2-1732579166967.png

step 2-remove point 3

AllanP_3-1732579197571.png

step3 remove another point, i selected  new point 4

AllanP_4-1732579243257.png

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

AllanP_5-1732581904462.png

 

"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

 

 

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

@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...😟

"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080

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:

n = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
 if isFirstRun then
 
endif .
By the way, it is usefull to specify all requirements for the object at the beginning. 
 
 
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

@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...

"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080

Try VALUES{2}

You can connect text type array to integer array.

- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

@Pertti Paasky, 

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..."

 

 
"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080

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.

HotspotMenu26.gif 😊😉😄

Now I'll get down to connecting INTEGER Values{2}...

"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080
Solution

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 😃

HotspotMenu_mymenu.gif😃😃😃😃😃😃

────────────────────────

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.

HotspotMenu_Pertti.gif

────────────────────────

Edit 2:

In order not to forget the whole idea of ​​the hotspot menu (because I have to leave this fun for later and focus on architecture), I prepared a template for practical use of the hotspot menu, so that it works like LEGO blocks.

This is an example of a library object with two groups of figures - circles and rectangles.

Both groups use their own data tables without any restrictions on the number of figures in the group.

Both groups can use a common universal subroutine (GOSUB "HotSpotMenu") to share the hotspot menu.

The CIRCLES group allows you to perform basic operations using the hotspot menu: moving/adding/removing circles.

The RECTANGLES group is more advanced, it also allows you to copy/paste using the hotspot menu: sizes/pen/rotation.
Of course, there can be more similar groups of "2D/3D figures" with specific properties that can be quickly controlled via the Hotspot menu (without opening the object settings window and wondering which figure I want to grab e.g. dimensions from and paste to another figure). Each group works with several parameters/variables, e.g.:
dim_rect_geom[][] — geometry (position, size of rectangle)
hot_rect_mnu[] — hotspot menu (VALUES{2}...)
hot_rect_mnu2[] — hotspot twin menu (VALUES{2}...)
hot_rect_mnu_id — INT returned number of the clicked hotspot
hot_rect_mnu_val — INT returned code (from VALUE{2}...) of the clicked hotspot
hot_rect_mnu_switch — menu switch 0/1 ..._mnu/..._mnu2
And rectangle properties:
hot_rect_rot[] — orientation angles of individual rectangles
hot_rect_pen[] — pens of individual rectangles
hot_rect_...[] — other rectangle properties
etc.
Of course, this is an object prototype and I understand that I ultimately need a GUI. But in this example I wanted to move some of the editing to where the "figures" are most visible (and accessible) - directly in the project. This is important, especially when there are more than a few "figures" in the library object.

HotspotMenu_template.gif

By the way, I fixed some minor bugs in the previous objects (HotspotMenu_Pertti.gsm, HotspotMenu.gsm).

"When you seek knowledge, you will eventually find it. Then you will become its source - until such time as you must seek it again."
AC 7 - 27 (28), Twinmotion | Windows 10 Pro for Workstations
Dell 7740 Xeon | 64GB | RTX 3000 6GB + LG 2560x1080

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!