GDL
About building parametric objects with GDL.

Tutorial for PUT&GET?

Mats_Knutsson
Advisor
Hi,
I've been looking for examples but haven't found any except for the manual. Any basic youtube (or other) tutorials someone know?
/Mats
AC 25 SWE Full

HP Zbook Fury 15,6 G8. 32 GB RAM. Nvidia RTX A3000.
8 REPLIES 8
Lingwisyer
Guru
There is a tube sample object from GS somewhere that uses it. I attached it in this thread. Not sure where the original post is.



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
Goker Altuntas
Contributor
Here is an example that I have made to obtain a polygon with desired number of edges:

3D Script:


!below, n represents the number of the edges. eEach stands for the angle between the lines
!that start from the centre and goes to the corners.

aEach = 360/n 

!The loop is to store the coordinates of the corner points. The centre of the polygon is at
! 0,0. Each time the loop is executed, the "PUT" command stores another corner 

for aTurn = 0 to 360 step aEach 
PUT	dCentreToCorner*cos(aTurn),  dCentreToCorner*sin(aTurn)

next aTurn

!Now all the stored data is going to be used in a PRISM command. Rather any parameters, the coordinates
!of the points come from the data stored.

PRISM n+1, ZZYZX,
get (nsp)
text2 0, dy * 2, "Goker Malik Altuntas"
DGSketcher
Legend
Do a search for GDL Cookbook 3 by David Nicholson-Cole. His book is a fantastic tutorial from beginner to advanced and in the later chapters he explains just how important Put & Get are to efficient GDL programming. It is getting a bit old now but the basics are still relevant, I think because of that you can find it in the public domain and there is I believe a web based version. Alternatively you could pay back his generous contribution to teaching GDL and buy a copy.
Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)
Mats_Knutsson
Advisor
I have the cookbook. Was looking for more examples like Gokers .
AC 25 SWE Full

HP Zbook Fury 15,6 G8. 32 GB RAM. Nvidia RTX A3000.
A_ Smith
Expert
here is not the best example of my post with put/get and here Kristian Bursell explain how to use it wiser

and here Peter Baksa has code with put/use
AC 22, 24 | Win 10
Mats_Knutsson
Advisor
A. wrote:
here is not the best example of my post with put/get and here Kristian Bursell explain how to use it wiser

and here Peter Baksa has code with put/use
Great! Thx.
AC 25 SWE Full

HP Zbook Fury 15,6 G8. 32 GB RAM. Nvidia RTX A3000.
What sort of function are you applying it to? Is it 3D or 2D geometry and if so what type of shape?
Polygons, Extrudes, Revolves are all easy because each line has the same number of values (usually 3; x, y, status) therefore when setting the number of nodes its "nsp/3".
However Tubes are more complex because they can have 3 values for the profile and 4 values for the path. therefore you can't divide the NSP (stored values) to get the node count. So in this case I follow each line with a counter like this (pay attention to the cntNSP_1 & cntNSP_2) :

cntNSP_1 = 0
cntNSP_2 = 0
for m = 1 to vardim1(_nodes_OESF_L)
	put -_nodes_OESF_L[xNde], _nodes_OESF_L[yNde], 0:	cntNSP_1 = cntNSP_1 +1
next m

put 0, 	StartY -.001, 0, 0:		cntNSP_2 = cntNSP_2 +1
put 0, 	StartY, 0, 0:			cntNSP_2 = cntNSP_2 +1
put 0, 	hOEsubFRAME, 0, 0:		cntNSP_2 = cntNSP_2 +1
put 0, 	hOEsubFRAME +.001, 0, 0:	cntNSP_2 = cntNSP_2 +1
tube cntNSP_1, cntNSP_2, 1+2+16+32,
	get(nsp)
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
Mats_Knutsson
Advisor
Kristian wrote:
What sort of function are you applying it to? Is it 3D or 2D geometry and if so what type of shape?
Polygons, Extrudes, Revolves are all easy because each line has the same number of values (usually 3; x, y, status) therefore when setting the number of nodes its "nsp/3".
However Tubes are more complex because they can have 3 values for the profile and 4 values for the path. therefore you can't divide the NSP (stored values) to get the node count. So in this case I follow each line with a counter like this (pay attention to the cntNSP_1 & cntNSP_2) :

cntNSP_1 = 0
cntNSP_2 = 0
for m = 1 to vardim1(_nodes_OESF_L)
	put -_nodes_OESF_L[xNde], _nodes_OESF_L[yNde], 0:	cntNSP_1 = cntNSP_1 +1
next m

put 0, 	StartY -.001, 0, 0:		cntNSP_2 = cntNSP_2 +1
put 0, 	StartY, 0, 0:			cntNSP_2 = cntNSP_2 +1
put 0, 	hOEsubFRAME, 0, 0:		cntNSP_2 = cntNSP_2 +1
put 0, 	hOEsubFRAME +.001, 0, 0:	cntNSP_2 = cntNSP_2 +1
tube cntNSP_1, cntNSP_2, 1+2+16+32,
	get(nsp)
Thanks! I'll dig into this. Just need a couple of hours of spare time.The original reason was that I wanted to add HEX colour values somewhere. Since I spent a week skiing with ny brother in law (IT-guy) we discussed some IT-related stuff and when he was explaining Json I imagined I could store whatever in Archicad the same way.

Back to adding materials to the BM-catalogue...
AC 25 SWE Full

HP Zbook Fury 15,6 G8. 32 GB RAM. Nvidia RTX A3000.