The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Topics specific to the scripting and development of Library Parts and Libraries using Param-O or the Geometric Description Language – GDL. (Example: How do you use “REQUEST” GDL commands?)

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, Gordana Radonic, nbalogh, mnguyen, gkmethy, rmasaki, Akos Somorjai, Csilla Mai, Peter Baksa

User avatar
By Mats_Knutsson
#322707
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
User avatar
By Lingwisyer
#322708
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.
User avatar
By Goker Malik Altuntas
#322710
Here is an example that I have made to obtain a polygon with desired number of edges:

3D Script:
Code: Select all

!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)
By DGSketcher
#322711
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.
User avatar
By Kristian Bursell
#322757
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) :
Code: Select all
cntNSP_1 = 0
cntNSP_2 = 0
for m = 1 to vardim1(_nodes_OESF_L)
	put -_nodes_OESF_L[m][xNde], _nodes_OESF_L[m][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)
User avatar
By Mats_Knutsson
#322775
Kristian Bursell wrote: Mon Feb 22, 2021 10:16 pm 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) :
Code: Select all
cntNSP_1 = 0
cntNSP_2 = 0
for m = 1 to vardim1(_nodes_OESF_L)
	put -_nodes_OESF_L[m][xNde], _nodes_OESF_L[m][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...