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

#320195
I personally use the PUT/GET statements for all my shapes because I hate changing the node quantity value in the "poly2_b" command every time I add a new node. Also most my shapes are parametric so the quantity of nodes changes based on the users application of the object, therefore I can't use anything but the PUT/USE/GET functions.

basic:
Code: Select all
poly2_b 4, 7, fill_pen, fill_background_pen,
    0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
smarter:
Code: Select all
put 0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
poly2_b nsp/3, 7, fill_pen, fill_background_pen,
      get(nsp)
smartest:
Code: Select all
put 0, 0, 1
put a, 0, 1
put a, b, 1
put 0, b, 1
poly2_b nsp/3, 7, fill_pen, fill_background_pen,
      get(nsp)
The last example makes it a lot easier to add nodes to your shape.
One thing to remember (especially when using the USE) function, is that you must remain aware of what is in your NSP. So if you are using the NSP values more then once, in a loop for instance and hence applying the USE function, then make sure the last call of the NSP values is a GET function, otherwise the values remain in the NSP and will populate the next unrelated GET function.
#320214
A. Smith wrote: Fri Dec 11, 2020 5:00 pm that should work

PARAMETER script
Code: Select all
values "ra" range[0, a/2]
values "rb" range[0, a/b]
2D script
Code: Select all
EPS=0.0001
Gs_resol = 72
st=1
if RA > EPS AND RB > EPS then
	put RA, 0, ST, 	!south line
		A-RA, 0, ST
	gosub "SE"	!south-east corner
	put A, RB, ST, 	!east line
		A, B-RB, ST
	gosub "NE"	!north-east corner
	put A-RA, B, ST, !north line
		RA, B, ST
	gosub "NW"	!north-west corner
	put 0, B-RB, ST, !west line
		0, RB, ST
	gosub "SW"	!south-west corner
else
	put 	0,	0,	ST,
		A,	0,	ST,
		A, 	B, 	ST,
		0, 	B, 	ST,
		0,	0, 	-1
endif
Poly2_B NSP/3, 7,19,19,
	get(nsp)

END	!__________________________END____________________

"SE":
	for n = 270 to 360 step 360/gs_resol
			put A-RA + RA*cos(n), RB + RB*sin(n), st
	next n
return

"NE":
	for n = 0 to 90 step 360/gs_resol
			put A-RA + RA*cos(n), B-RB + RB*sin(n), st
	next n
return


"NW":
	for n = 90 to 180 step 360/gs_resol
			put RA + RA*cos(n), B-RB + RB*sin(n), st
	next n
return


"SW":
	for n = 180 to 270 step 360/gs_resol
			put RA + RA*cos(n), RB + RB*sin(n), 1
	next n
return
Edit: you must create parameters RA and RB
Thanks so much! Worked a charm! I had tried using Gosub and putting it inside the Poly command...now seeing your solution I see how that didn't work... :?
Hopefully my questions will become less naive over time :wink:
#320215
Kristian Bursell wrote: Sun Dec 13, 2020 11:42 pm I personally use the PUT/GET statements for all my shapes because I hate changing the node quantity value in the "poly2_b" command every time I add a new node. Also most my shapes are parametric so the quantity of nodes changes based on the users application of the object, therefore I can't use anything but the PUT/USE/GET functions.

basic:
Code: Select all
poly2_b 4, 7, fill_pen, fill_background_pen,
    0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
smarter:
Code: Select all
put 0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
poly2_b nsp/3, 7, fill_pen, fill_background_pen,
      get(nsp)
smartest:
Code: Select all
put 0, 0, 1
put a, 0, 1
put a, b, 1
put 0, b, 1
poly2_b nsp/3, 7, fill_pen, fill_background_pen,
      get(nsp)
The last example makes it a lot easier to add nodes to your shape.
One thing to remember (especially when using the USE) function, is that you must remain aware of what is in your NSP. So if you are using the NSP values more then once, in a loop for instance and hence applying the USE function, then make sure the last call of the NSP values is a GET function, otherwise the values remain in the NSP and will populate the next unrelated GET function.
It's starting to make a lot more sense now! I'd seen it in other scripts before but it always seemed very daunting to implement.
#320739
Arnaut2604 wrote: Thu Dec 10, 2020 12:41 pm Is it possible to get an ellipsoidal curve without using mul?

On example 1 on the Additional Status Codes site is a ellipsodial curve but I can't seem to fathom how it works.
Through deleting lines and seeing what happens I've figured out that is has something to do with status code 2000
https://gdl.graphisoft.com/reference-gu ... atus-codes
No, it isn't possible. You could use SPLINE2 to approximate it, but that's not available as status codes in any command.

That part in the example isn't an ellipse, just two tangential arcs:
1, 90, 2000 is an arc with radius 1 and 90°
2, 3, 1001 is an arc tangential to the previous and ending at (2,3)