GDL
About building parametric objects with GDL.

Inserting Code Into Command (Adding/Subtracting Nodes From Slab)

Benji_W
Booster

I apologize for not knowing how to word the title properly – still starting out with GDL. I just need pointed in the right direction.

 

Say I'm creating a SLAB in GDL. And let's say that I want to create a variable number of nodes (n = variable). Obviously, if I change the number of nodes from 3 to 4, then AC is going to be looking for 3 additional parameters (x4, y4, z4) which aren't there. Or, if reducing the number of nodes, then it will see too many parameters.

 

What's the best approach for inserting/removing these additional/unnecessary parameters?

 

On a related note: Is it possible to somehow insert a few lines of code halfway through a command, and have AC recognize the inserted lines as part of the command? My first thought to resolve this issue was to use a GOSUB within the SLAB command (after defining the number of nodes and height, but prior to defining the xyz coordinates of the individual nodes) that would insert the desire list of parameters (including commas and all), but "Keywords can't be used as variables".

 

 

Thanks In Advance,

 

-Ben

Archicad 25 – macOS Big Sur 11.6.1 – 27" iMac 2017
6 REPLIES 6

Hi Ben,

For adding nodes you use "dynamic array" parameters. Any parameter can be made into an array by turning on the array function.

Arrays.png

 

You can have 1D or 2D arrays; 1D being a 1 column with multiple rows of values and 2D being multiple columns and rows. The examples above are both 2D.

 

You then set this array to grow and shrink based on the number of nodes by using a loop statement in the master/parameter script. Using the values in the image above would look like this (note I have 6 columns but you only need 3 (x, y, z)) :

 

xNde = 1

yNde = 2

zNde = 3

dim _nodes_MuPr_2[][]

for i = 1 to qNodes_MuPr_2

    if i > vardim1(nodes_MuPr_2) then

        _nodes_MuPr_2[i][xNde] = 0

        _nodes_MuPr_2[i][yNde] = 0

        _nodes_MuPr_2[i][zNde] = 0

    else

        _nodes_MuPr_2[i][xNde] = nodes_MuPr_2[i][xNde]

        _nodes_MuPr_2[i][yNde] = nodes_MuPr_2[i][yNde]

        _nodes_MuPr_2[i][zNde] = nodes_MuPr_2[i][zNde]

    endif

next i

nodes_MuPr_2 = _nodes_MuPr_2

parameters nodes_MuPr_2 = nodes_MuPr_2

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

If you download one of the objects in my signature you can experiment. The top and bottom shapes are all likes this in the objects.

Pertti Paasky
Expert

Hi Benji_W


This should work. You just use put and get.
You may add or remove lines. Nsp is the number of puts, so the number of nodes is nsp/3.
 
 

 

x1=0.0 : y1=0.0

x2=1.0 : y2=0.0

x3=1.0 : y3=1.0

x4=0.0 : y4=1.0

put  x1 , y1 , 15,

      x2 , y2 , 15,

      x3 , y3 , 15,

      x4 , y4 , 15

prism_  nsp/3, 1 , get(nsp)

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

Could you utilise the Dynamic Polyline object floating around on here?

 

https://community.graphisoft.com/t5/Developer-forum/Dynamic-Polyline-base-code-object-VERSION-2/m-p/...

 

 

 

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

Try this.

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

So sorry for the delayed response everyone! Work picked up, and I had to set aside the non-billable GDL work (you all know how it is). 

 

These are all fantastic suggestions. It's really great to have such an active community for such a niche topic! I've got some tinkering to do, but should have everything I need to get started. 

 

-Ben

Archicad 25 – macOS Big Sur 11.6.1 – 27" iMac 2017