BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
GDL
About building parametric objects with GDL.

Can I script a parametric ellipsoidal shape?

JGoode
Advocate
Hello,

I've attached an image and I was wondering how to do it. Firstly, is this achievable?
The idea is basically to create a rounded shape but allow these dimensions to be added in to create it.

Any help would be much appreciated.
Thanks
ArchiCAD 23

Windows 10
23 REPLIES 23
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:

poly2_b 4, 7, fill_pen, fill_background_pen,
    0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
smarter:

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:

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.
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
Anonymous
Not applicable
A. wrote:
that should work

PARAMETER script
values "ra" range[0, a/2]
values "rb" range[0, a/b]
2D script
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
Anonymous
Not applicable
Kristian wrote:
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:

poly2_b 4, 7, fill_pen, fill_background_pen,
    0, 0, 1,
    a, 0, 1,
    a, b, 1,
    0, b, 1
smarter:

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:

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.
Peter Baksa
Graphisoft
Graphisoft
Arnaut2604 wrote:
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-guide/additional-status-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)
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Learn and get certified!