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

GDL
About building parametric objects with GDL.

Dynamic Polyline base code object

sinceV6
Advocate
Hello everyone.

In the past couple of months I've been in a GDL streak creating, updating and fixing lots of little self made parts... and the code just seemed to flow; so I tackled my wish to have (make, to learn, in my case) a dynamic polyline. A few months ago, I sketched a new "parking place" object that I wanted, but just didn't have the time to do; and didn't really need because I've just been adding stuff and parameters to the GS parking place object for years.

I did some research a few years ago, but just kept the links for reference. Now that I was naturally digging into GDL again, I though I could make it possible.

The basic code for a Dynamic Polyline is useful for me; and I thought many people here could benefit from it. I tried several approaches for two weeks trying to make it work the way I wanted (I'm really no expert in GDL). It solves a few issues and serves as learning resource too, as it dynamically adds points to the polyline between segments, adds points at the end, dynamically removes points and dynamically grows and shrinks arrays.

I already have other ideas for this, like a 3D railing (the code already has Z for each point). I'm not putting it in BIMcomponents (this is for AC15+) or the Depository as it is not a final product.

I hope you find it useful, if you do, leave a comment; the only condition is that if you use it for something, you must post back the developed object with the code unlocked so other people can see how to implement it in new objects. (so please, no locked commercial derivatives... this is for the community)

Thanks to the plethora of information found in this community.
 

Enjoy.

The "Dynamic Polyline ER" base code object:

EDIT: new version: added a few things, like length of the segments, and a visual constraint for the first segment to keep at least 2 points.
47 REPLIES 47

Thanks!  Very usefull.  Is it also possible to add a fill?

I am trying to make an object using 3 different transparant fills on top of each other.

 

Apple M1 Max 32 GB Ventura
AC27

You can add a fill by copying the snippet below to the object's 2D code section.

fill 2 ! or whatever you want
for i = 1 to points
	put xx[i], yy[i]
next i
poly2 nsp/2, 1+2+4, get(nsp)

 

 

 

Thanks a lot! Just what I needed. Works perfect!

Apple M1 Max 32 GB Ventura
AC27
I need to have a transparant fill and need to use poly2_b.  Where/how do i setup the s1,....,s1?
 
 POLY2_B n, frame_fill,
fill_pen, fill_background_pen,
x1, y1, s1, ..., xn, yn, sn
Apple M1 Max 32 GB Ventura
AC27

Try something like ...

 

for i = 1 to points
put xx[i], yy[i], s[i]
next i
poly2_B nsp/3, 1+2+4,

fill_pen, fill_background_pen,

get(nsp)

 

You have to add the status code to your PUT statements.

,s[i] could probably just be replaced with ,1 if you want all the edges visible.

Change the number of nodes to allow for the fact you are PUTing 3 values now.

Adjust the POLY command.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Thanks Barry!  

The script works but i get a remark when I try to set the values of the s[i] to the same value

"Possibly unwanted parameter type change

at line 52 in the 2D script"

 

for i=1 to points
s[i]=1
next i
 
 

 

Apple M1 Max 32 GB Ventura
AC27

If it is always going to be '1' then I would try ...

 

for i = 1 to points
put xx[i], yy[i], 1
next i

 

And not worry about setting the array values for s[i]

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

In fact I added a fill to a polyline object just a little while ago.

 

BarryKelly_0-1699950608605.png

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!