Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Shrinking a Dynamic Array

DGSketcher
Rockstar

I have a two dimensional parameter array which by default is dynamic and grows according to the number of elements in my parametric object. What I am wondering is how do you get the array to shrink if the object no longer needs as many points e.g. if A = 10 it creates an array of 10 points but if I reduce A to 5 I am still left with a 10 point array?

 

I am trying to avoid having a parameter array for 100 x 20 = 2000 values when I might only need 5 x 20 = 100 values.

Apple iMac macOS Monterey / AC25UKI (most recent builds)
3 REPLIES 3

I control the growing and shrinking of all my arrays (I have hundreds across my objects) using the following technique (master script):

 

!!array name = arrName
!!array rows = rowDim

dim _arrName[]

for i = 1 to rowDim
    if i > vardim1(arrName) then
        _arrName = 0          !!depends on the type of parameter; could be string ""
    else
        _arrName = arrName
    endif
next i

arrName = _arrName
parameters arrName = arrName

 

This sets the size of the array to a locally declared array and then maps the parameter array to the local array.

 

It also means you can use the latest array values, before they are updated in the parameter array, by referencing the local array instead (_arrayName). This is the most important feature as it makes the object respond more dynamically.

 

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

DGSketcher
Rockstar

@Kristian Bursell Thank you ! I did try assigning a local array but it didn't seem to work. Up and running now. I have consolidated your suggestion as my object array values are always rebuilt from scratch while being added to the parameter. Basically I have set the local array to be 1 x 1 and use that to reset the parameter.

!Create local single cell array
DIM _arrNull[1][1]
_arrNull[1][1] = 0.0
arrName = _arrNull
PARAMETERS arrName = arrName
...
!Add new values to parameter array

 

Apple iMac macOS Monterey / AC25UKI (most recent builds)

A_ Smith
Enthusiast

Maybe this is something similuar to your approach thread 

AC 22, 24 | Win 10

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!