We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.
SOLVED!

Hotspot "array" static hotspots

GDL Enthusiast
Enthusiast

Hi,

 

I have a list of hotspots that I thought could be cleaned up with an array.

 

When implemented

 

unID = 1
HOTSPOT X1, 0, 0, unID, Len1, 1+128 :unID=unID+1 !Point
HOTSPOT X1, 0+Len1, 0, unID, Len1, 2 :unID=unID+1 !Move
HOTSPOT X1, 0-1, 0, -unID, Len1, 3 :unID=unID+1 !Ref

 

within a loop using an array, the hotspots all turn to static hotspots.

 

Here is the code that works in the standard way (repeat for next 12 hotspots):

 

Here is the code using a loop that produces static hotspots instead of dynamic:

 

! Note, X[i] and Len[i] are declared arrays with defined values:
unID = 1
FOR i = 1 TO 12
HOTSPOT X[i], 0, 0, unID, Len[i], 1+128 :unID=unID+1 !Point
HOTSPOT X[i], 0+Len[i], 0, unID, Len[i], 2 :unID=unID+1 !Move
HOTSPOT X[i], 0-1, 0, -unID, Len[i], 3 :unID=unID+1 !Ref
Next i

 

What could be changed in the code to make the hotspots return to being dynamic within the loop?

 

Any help most welcome.

 

Many thanks, Matt

2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution
Hi Matt.
I simplified a 2d sample of an array of lines, with varying length, using your variable.
You can apply a similar concept out of this.
 
!2d script
 
 
unID = 1

FOR   i = 1  TO   12   ! e.g. row of lines
 
 add2 0, i   ! draw number of rows
 
 line2  0, 0,     Len1[i],0  !sample vector, distinct length per row

HOTSPOT2  0, 0,           unID, len1[i], 1 :unID=unID+1 !Point
HOTSPOT2 Len1[i], 0,      unID, Len1[i], 2 :unID=unID+1 !Move
HOTSPOT2 -1, 0,          -unID, Len1[i], 3 :unID=unID+1 !Ref
  del 1
 
Next i
 
ToperBarrientos_0-1711163573169.png

 

Apple M1 Pro CPU
RAM 32 GB
1 TB OS: Ventura 13.1

View solution in original post

Solution
Lingwisyer
Guru

If you did not replace your placed object after you changed your parameter to an array it will not work properly as the old objects values are not defined properly, it is not looking for an array. The same thing happens when you change the size of an array. When changing a parameter to an array type, I will usually delete the parameter, save it which will brick any existing objects, then recreate the parameter. You can also initiallise the array at the start of your script or in the parameter script then go and redefine each paramter value through a loop. Required if you are dynamically changing the array size.

 

Ling.

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

View solution in original post

5 REPLIES 5
Solution
Hi Matt.
I simplified a 2d sample of an array of lines, with varying length, using your variable.
You can apply a similar concept out of this.
 
!2d script
 
 
unID = 1

FOR   i = 1  TO   12   ! e.g. row of lines
 
 add2 0, i   ! draw number of rows
 
 line2  0, 0,     Len1[i],0  !sample vector, distinct length per row

HOTSPOT2  0, 0,           unID, len1[i], 1 :unID=unID+1 !Point
HOTSPOT2 Len1[i], 0,      unID, Len1[i], 2 :unID=unID+1 !Move
HOTSPOT2 -1, 0,          -unID, Len1[i], 3 :unID=unID+1 !Ref
  del 1
 
Next i
 
ToperBarrientos_0-1711163573169.png

 

Apple M1 Pro CPU
RAM 32 GB
1 TB OS: Ventura 13.1
GDL Enthusiast
Enthusiast

Hi Toper, 

 

Thank you for your coding! I am super perplexed as your code works fine for me also when separated from my object. When I try the code in my object, it returns a simple static hotspot no matter what options of code I try using in the array. I read here of a similar issue:

 

https://community.graphisoft.com/t5/Libraries-objects/GDL-Editable-3D-Hotspot-within-Array/td-p/2975...

 

Their solution of adding a glob_modpar statement, is confusing. I am unsure what it would change? Maybe it is needed to cause the code to run again. Any thoughs most welcome. 

 

Many thanks, Matt

Solution
Lingwisyer
Guru

If you did not replace your placed object after you changed your parameter to an array it will not work properly as the old objects values are not defined properly, it is not looking for an array. The same thing happens when you change the size of an array. When changing a parameter to an array type, I will usually delete the parameter, save it which will brick any existing objects, then recreate the parameter. You can also initiallise the array at the start of your script or in the parameter script then go and redefine each paramter value through a loop. Required if you are dynamically changing the array size.

 

Ling.

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

Hi Ling,

 

Thank you for your guidance. I am still unsuccessful after all this time with this particular set of array hotspots. Very confusing as to why it doesn't work in the object. I am happy to use the basic multi-line method for now as the object is working. Wishing you the best, Matt

Lingwisyer
Guru

Did you initiallise your arrays?

DIM X[ ]

DIM Len[ ]

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