2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2023-04-05 05:53 AM - edited 2023-04-06 04:31 AM
Hi all,
I have 2 integer parameters, x and y which are each linked to the size of 9 other array parameters, 4 unique and 5 common. These common arrays only update if the modification of x or y is greater than the other, max(x ,y).
When I modify x all 9 relevant arrays update. The issue is that when I modify y, it's relevant 8 arrays DO NOT update UNTIL you modify x... This though highly inconvenient is managable as you can follow up any changed to y with an increase to x before reverting it's value inorder to get everything to update. The major issue is that there is one array (sg_customBasePrefix) that does not update at all meaning that the object breaks if you increase y beyond the existing size of this array...
The current object can be found over at this thread.
Ling.
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 |
2023-04-11 05:40 AM
!========== Levels Array ==========
IF sg_base_toggle then sg_noStoreyAbove = sg_noStoreyAbove + 1
IF GLOB_MODPAR_NAME = "sg_noStoreyAbove" then
name = sg_name_prefix + STR ("%2.0", i)
! allow decrease, vardim1 tells stored array vertical size
sizetokeep = min(vardim1(sg_custom), sg_noStoreyAbove)
! copy existing values
dim sg_styToSty_temp[]
dim sg_custom_temp[]
dim sg_customName_temp[][]
dim sg_customPrefix_temp[][]
for i = 1 to sizetokeep
sg_styToSty_temp[i] = sg_styToSty[i]
sg_custom_temp[i] = sg_custom[i]
sg_customName_temp[i][1] = name
sg_customName_temp[i][2] = sg_customName[i][2]
sg_customPrefix_temp[i][1] = name
sg_customPrefix_temp[i][2] = sg_customPrefix[i][2]
next i
! initialize new values, will be skipped when decreasing size
for i = sizetokeep + 1 to sg_noStoreyAbove
sg_styToSty_temp[i] = sg_styToSty_def
sg_custom_temp[i] = 0
sg_customName_temp[i][1] = name
sg_customName_temp[i][2] = 0
sg_customPrefix_temp[i][1] = name
sg_customPrefix_temp[i][2] = ""
next i
! store array with new size
sg_styToSty = sg_styToSty_temp
sg_custom = sg_custom_temp
sg_customName = sg_customName_temp
sg_customPrefix = sg_customPrefix_temp
parameters sg_styToSty = sg_styToSty_temp
parameters sg_custom = sg_custom
parameters sg_customName = sg_customName
parameters sg_customPrefix = sg_customPrefix
endIF
FOR i = 1 to sg_noStoreyAbove
name = sg_name_prefix + STR ("%2.0", i)
IF sg_custom[i] # 0 then PARAMETERS sg_customName[i][1] = name
next i
!========== Basement Array ==========
IF GLOB_MODPAR_NAME = "sg_noBasement" then
name = sg_nameBase_prefix + STR ("%2.0", j)
! allow decrease, vardim1 tells stored array vertical size
sizetokeep = min(vardim1(sg_customBase), sg_noBasement)
! copy existing values
dim sg_basementHTs_temp[]
dim sg_customBase_temp[]
dim sg_customBaseName_temp[][]
dim sg_customBasePrefix_temp[][]
for j = 1 to sizetokeep
sg_basementHTs_temp[j] = sg_basementHTs[j]
sg_customBase_temp[j] = sg_customBase[j]
sg_customBaseName_temp[j][1] = name
sg_customBaseName_temp[j][2] = sg_customBaseName[j][2]
sg_customBasePrefix_temp[i][1] = name
sg_customBasePrefix_temp[i][2] = sg_customBasePrefix[i][2]
next j
! initialize new values, will be skipped when decreasing size
for j = sizetokeep + 1 to sg_noBasement
sg_basementHTs_temp[j] = sg_styToSty_def
sg_customBase_temp[j] = 0
sg_customBaseName_temp[j][1] = name
sg_customBaseName_temp[j][2] = 0
sg_customBasePrefix_temp[i][1] = name
sg_customBasePrefix_temp[i][2] = ""
next j
! store array with new size
sg_basementHTs = sg_basementHTs_temp
sg_customBase = sg_customBase_temp
sg_customBaseName = sg_customBaseName_temp
sg_customBasePrefix = sg_customBasePrefix_temp
parameters sg_basementHTs = sg_basementHTs
parameters sg_customBase = sg_customBase
parameters sg_customBaseName = sg_customBaseName
parameters sg_customBasePrefix = sg_customBasePrefix
endIF
FOR j = 1 to sg_noBasement
name = sg_nameBase_prefix + STR ("%2.0", j)
IF sg_customBase[j] # 0 then PARAMETERS sg_customBaseName[j][1] = name
next j
!========== Grid Lengths Array ==========
IF GLOB_MODPAR_NAME = "sg_noStoreyAbove" | GLOB_MODPAR_NAME = "sg_noBasement" then
IF sg_base_toggle then sg_noStoreyAbove = sg_noStoreyAbove + 1
IF sg_noStoreyAbove > sg_noBasement then
sizetokeep = min(vardim1(sg_customName), sg_noStoreyAbove)
! copy existing values
dim sg_lengthCustom_temp[][]
dim sg_lengthCustom2_temp[][]
dim sg_lengthToggle_temp[][]
dim lp1_temp[][]
dim lp2_h_temp[][]
dim lp2_v_temp[][]
for i = 1 to sizetokeep
sg_lengthCustom_temp[i][1] = sg_lengthCustom[i][1]
sg_lengthCustom_temp[i][2] = sg_lengthCustom[i][2]
sg_lengthCustom2_temp[i][1] = sg_lengthCustom2[i][1]
sg_lengthCustom2_temp[i][2] = sg_lengthCustom2[i][2]
sg_lengthToggle_temp[i][1] = sg_lengthToggle[i][1]
sg_lengthToggle_temp[i][2] = sg_lengthToggle[i][2]
lp1_temp[i][1] = lp1[i][1]
lp1_temp[i][2] = lp1[i][2]
lp1_temp[i][3] = lp1[i][3]
lp1_temp[i][4] = lp1[i][4]
lp2_h_temp[i][1] = lp2_h[i][1]
lp2_h_temp[i][2] = lp2_h[i][2]
lp2_h_temp[i][3] = lp2_h[i][3]
lp2_h_temp[i][4] = lp2_h[i][4]
lp2_v_temp[i][1] = lp2_v[i][1]
lp2_v_temp[i][2] = lp2_v[i][2]
lp2_v_temp[i][3] = lp2_v[i][3]
lp2_v_temp[i][4] = lp2_v[i][4]
next i
! initialize new values, will be skipped when decreasing size
for i = sizetokeep + 1 to sg_noStoreyAbove
sg_lengthCustom_temp[i][1] = sg_length
sg_lengthCustom_temp[i][2] = 0
sg_lengthCustom2_temp[i][1] = 0
sg_lengthCustom2_temp[i][2] = 0
sg_lengthToggle_temp[i][1] = 0
sg_lengthToggle_temp[i][2] = 0
lp1_temp[i][1] = marker_length/4
lp1_temp[i][2] = marker_length/4
lp1_temp[i][3] = marker_length/4
lp1_temp[i][4] = marker_length/4
lp2_h_temp[i][1] = marker_length/4
lp2_h_temp[i][2] = marker_length/4
lp2_h_temp[i][3] = marker_length/4
lp2_h_temp[i][4] = marker_length/4
lp2_v_temp[i][1] = 0
lp2_v_temp[i][2] = 0
lp2_v_temp[i][3] = 0
lp2_v_temp[i][4] = 0
next i
! store array with new size
sg_lengthCustom = sg_lengthCustom_temp
sg_lengthCustom2 = sg_lengthCustom2_temp
sg_lengthToggle = sg_lengthToggle_temp
lp1 = lp1_temp
lp2_h = lp2_h_temp
lp2_v = lp2_v_temp
parameters sg_lengthCustom = sg_lengthCustom
parameters sg_lengthCustom2 = sg_lengthCustom2
parameters sg_lengthToggle = sg_lengthToggle
parameters lp1 = lp1
parameters lp2_h = lp2_h
parameters lp2_v = lp2_v
ELSE
sizetokeep = min(vardim1(sg_customBaseName), sg_noBasement)
! copy existing values
dim sg_lengthCustom_temp[][]
dim sg_lengthCustom2_temp[][]
dim sg_lengthToggle_temp[][]
dim lp1_temp[][]
dim lp2_h_temp[][]
dim lp2_v_temp[][]
for i = 1 to sizetokeep
sg_lengthCustom_temp[i][1] = sg_lengthCustom[i][1]
sg_lengthCustom_temp[i][2] = sg_lengthCustom[i][2]
sg_lengthCustom2_temp[i][1] = sg_lengthCustom2[i][1]
sg_lengthCustom2_temp[i][2] = sg_lengthCustom2[i][2]
sg_lengthToggle_temp[i][1] = sg_lengthToggle[i][1]
sg_lengthToggle_temp[i][2] = sg_lengthToggle[i][2]
lp1_temp[i][1] = lp1[i][1]
lp1_temp[i][2] = lp1[i][2]
lp1_temp[i][3] = lp1[i][3]
lp1_temp[i][4] = lp1[i][4]
lp2_h_temp[i][1] = lp2_h[i][1]
lp2_h_temp[i][2] = lp2_h[i][2]
lp2_h_temp[i][3] = lp2_h[i][3]
lp2_h_temp[i][4] = lp2_h[i][4]
lp2_v_temp[i][1] = lp2_v[i][1]
lp2_v_temp[i][2] = lp2_v[i][2]
lp2_v_temp[i][3] = lp2_v[i][3]
lp2_v_temp[i][4] = lp2_v[i][4]
next i
! initialize new values, will be skipped when decreasing size
for i = sizetokeep + 1 to sg_noBasement
sg_lengthCustom_temp[i][1] = 0
sg_lengthCustom_temp[i][2] = sg_length
sg_lengthCustom2_temp[i][1] = 0
sg_lengthCustom2_temp[i][2] = 0
sg_lengthToggle_temp[i][1] = 0
sg_lengthToggle_temp[i][2] = 0
lp1_temp[i][1] = marker_length/4
lp1_temp[i][2] = marker_length/4
lp1_temp[i][3] = marker_length/4
lp1_temp[i][4] = marker_length/4
lp2_h_temp[i][1] = marker_length/4
lp2_h_temp[i][2] = marker_length/4
lp2_h_temp[i][3] = marker_length/4
lp2_h_temp[i][4] = marker_length/4
lp2_v_temp[i][1] = 0
lp2_v_temp[i][2] = 0
lp2_v_temp[i][3] = 0
lp2_v_temp[i][4] = 0
next i
! store array with new size
sg_lengthCustom = sg_lengthCustom_temp
sg_lengthCustom2 = sg_lengthCustom2_temp
sg_lengthToggle = sg_lengthToggle_temp
lp1 = lp1_temp
lp2_h = lp2_h_temp
lp2_v = lp2_v_temp
parameters sg_lengthCustom = sg_lengthCustom
parameters sg_lengthCustom2 = sg_lengthCustom2
parameters sg_lengthToggle = sg_lengthToggle
parameters lp1 = lp1
parameters lp2_h = lp2_h
parameters lp2_v = lp2_v
endIF
endIF
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 |
2023-04-12 09:47 AM
Hi,
not sure if it helps, but maybe the confusion comes from using GLOB_MODPAR_NAME. That only contains the name of the parameter which the user modified manually. It doesn't react to PARAMETERS commands in the code.
2023-04-12 10:55 AM
I found the issue. I had two i where there should have been j... That was why that one parameter was not updating, and apparently the reason why the others where only updating when the other set of arrays were updated... maybe I should have used letters which did not look so similar... Another facepalm moment...
Ling.
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 |