2024-08-13 03:12 PM
Hello!
I have a building object where number of stories can be set and edited with a graphical hotspot. This number is an integer. When I edit it in 3D it is read as meters, meaning if I move the hotspot to 12 meters above the ground I get 12 stories. I would like to divide this by 3, so I get a new story every 3 meters. Is there any way to do this?
Even better would be if the story height could be read as well (which also can be edited), but 3 meters will do fine if it's not possible.
Thank you!
/Kaj
Solved! Go to Solution.
2024-08-13 03:44 PM
I use 3 parameters: the number of stories (int_anz_geschosse), the story height (z_geschoss) and the building height (z_story).
Parameter-Script
DIM story_z[]
FOR i = 1 TO 100
story_z[i] = i * z_geschoss
NEXT i
VALUES "z_story" story_z
IF GLOB_MODPAR_NAME = "int_anz_geschosse" THEN
z_story = int_anz_geschosse * z_geschoss
PARAMETERS z_story = z_story
ENDIF
IF GLOB_MODPAR_NAME = "z_story" THEN
int_anz_geschosse = z_story / z_geschoss
PARAMETERS int_anz_geschosse = int_anz_geschosse
ENDIF
3D-Script
HOTSPOT 0, 0, - 0.1, htps + 1, z_story, 3
HOTSPOT 0, 0, 0, htps + 2, z_story, 1 + 128
HOTSPOT 0, 0, z_story, htps + 3, z_story, 2, int_anz_geschosse
htps = htps + 3
2024-08-14 01:41 PM
Yes, you can create an Array-Parameter for this purpose with different heights for each story. Use UI_INFIELD{2} arry_name[i] in the user interface.
If z_geschoss is the name of your story-height array parameter, write instead of this:
FOR i = 1 TO 100
story_z[i] = i * z_geschoss
NEXT i
this:
st_hit = 0
FOR i = 1 TO VARDIM1(z_geschoss)
st_hit = st_hit + z_geschoss[i]
story_z[i] = st_hit
NEXT i
I hope it works (I did not try)
2024-08-13 03:44 PM
I use 3 parameters: the number of stories (int_anz_geschosse), the story height (z_geschoss) and the building height (z_story).
Parameter-Script
DIM story_z[]
FOR i = 1 TO 100
story_z[i] = i * z_geschoss
NEXT i
VALUES "z_story" story_z
IF GLOB_MODPAR_NAME = "int_anz_geschosse" THEN
z_story = int_anz_geschosse * z_geschoss
PARAMETERS z_story = z_story
ENDIF
IF GLOB_MODPAR_NAME = "z_story" THEN
int_anz_geschosse = z_story / z_geschoss
PARAMETERS int_anz_geschosse = int_anz_geschosse
ENDIF
3D-Script
HOTSPOT 0, 0, - 0.1, htps + 1, z_story, 3
HOTSPOT 0, 0, 0, htps + 2, z_story, 1 + 128
HOTSPOT 0, 0, z_story, htps + 3, z_story, 2, int_anz_geschosse
htps = htps + 3
2024-08-14 03:18 AM - edited 2024-08-14 03:23 AM
The main point there being that you have used your Storey count as your distance vector, and given GDL is written in meters, we get the result presented. To get around that you use the Hotspot Display Parameter to provide your desired feedback while using Building Height for the distance vector.
Regarding your Storey Height, can you just use a second set of Hotspots?
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2024-08-14 10:21 AM
Thank you!
It took me some time to figure out what this does, but it does work really nicely!
/Kaj
2024-08-14 10:33 AM
Thanks for the response! I have every storey's height as a separate parameter (storey_height_01, storey_height_02 etc.), which means (I think?) that I have to write code for every storey. Do you know of any way to work around this? Is there for example any way to put an array as a parameter instead, while still making it look like the image below?
2024-08-14 01:41 PM
Yes, you can create an Array-Parameter for this purpose with different heights for each story. Use UI_INFIELD{2} arry_name[i] in the user interface.
If z_geschoss is the name of your story-height array parameter, write instead of this:
FOR i = 1 TO 100
story_z[i] = i * z_geschoss
NEXT i
this:
st_hit = 0
FOR i = 1 TO VARDIM1(z_geschoss)
st_hit = st_hit + z_geschoss[i]
story_z[i] = st_hit
NEXT i
I hope it works (I did not try)
2024-08-14 01:50 PM
Oh my, that is so simple. It will reduce my code to a fourth of what it is now. Thank you so much!
2024-08-15 02:01 PM
Hello again!
I changed my parameters into arrays, which worked great for almost everything. However, the hotspots controlling the individual story height now don't align with the actual stories. Any ideas where this issue might come from? I'll attach the code but it might be quite tricky to read. Please ask if I can clarify anything.
!floor_height[] is the array I want to control. It can be used if I don't want to use the main height on a level.
!story_height[] is an array of the actual height of each story. Every story_height[] comes from either the floor_height[] or a parameter called main_height.
FOR i=1 TO num_stories
currentHeight=0
FOR j=1 TO i
currentHeight=currentHeight+story_height[i]
NEXT j
FOR j=1 TO numNodes-1
!Story height hotspots
unID=unID+1 : HOTSPOT ac_coords[j][2], ac_coords[j][3], currentHeight-story_height[i], unID, floor_height[i], 1 + 128
unID=unID+1 : HOTSPOT ac_coords[j][2], ac_coords[j][3], currentHeight, unID, floor_height[i], 2
unID=unID+1 : HOTSPOT ac_coords[j][2], ac_coords[j][3], -1, unID, floor_height[i], 3
!Height override hotspots
unID=unID+1 : HOTSPOT (ac_coords[j][2]+ac_coords[j+1][2])/2, (ac_coords[j][3]+ac_coords[j+1][3])/2,
currentHeight-override_height[i], unID, override_height[i], 1 + 128 !base
unID=unID+1 : HOTSPOT (ac_coords[j][2]+ac_coords[j+1][2])/2, (ac_coords[j][3]+ac_coords[j+1][3])/2,
currentHeight, unID, override_height[i], 2 !moving
unID=unID+1 : HOTSPOT (ac_coords[j][2]+ac_coords[j+1][2])/2, (ac_coords[j][3]+ac_coords[j+1][3])/2,
-1, unID, override_height[i], 3 !reference
NEXT j
NEXT i