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
Peter Baksa
Graphisoft
Graphisoft
Yes, use poly2_ with additional status codes.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Anonymous
Not applicable
Exactly Peter.
Here it is:
HOTSPOT2 0, 0

FILL MyFill

mul2 1, lTopHeight
mul2 lRightWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			0,		0.5,	32, 
			0,		0,		32, 
			0.5,	0,		33, 
			0,		0,		900, 
			0,		90,		4032
del 1

mul2 lLeftWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			-0.5,		0,	32, 
			0,		0,		32, 
			0,	0.5,		33, 
			0,		0,		900, 
			0,		90,		4032

del 1
del 1
mul2 1, lBottomHeight
mul2 lRightWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			0,		-0.5,	32, 
			0,		0,		32, 
			0.5,	0,		33, 
			0,		0,		900, 
			0,		-90,	4032

del 1
mul2 lLeftWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			-0.5,	0,		32, 
			0,		0,		32, 
			0,		-0.5,	33, 
			0,		0,		900, 
			0,		-90,	4032

del 1
del 1
Peter Baksa
Graphisoft
Graphisoft
It is also important to set the proper RESOL or TOLER, the ellipsoid arcs will be approximated with straight segments.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Anonymous
Not applicable
Ok. I posted the code without testing it. The dimensions were set for diameters. Here is the correct code with more HOTSPOTS and a proper RESOL command, well pointed by Peter.
Cheers,
RESOL 32 !Curve Resolution (Number of Segments)

lRightWidth = 1.0
lLeftWidth = 1.5
lTopHeight = 2.0
lBottomHeight = 2.5

HOTSPOT2 0, 0
HOTSPOT2 0, lTopHeight
HOTSPOT2 -lLeftWidth, 0
HOTSPOT2 lRightWidth, 0
HOTSPOT2 0, -lBottomHeight

FILL MyFill

mul2 1, lTopHeight
mul2 lRightWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			0,		1,	32, 
			0,		0,		32, 
			1,	0,		33, 
			0,		0,		900, 
			0,		90,		4032
del 1

mul2 lLeftWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			-1,		0,	32, 
			0,		0,		32, 
			0,	1,		33, 
			0,		0,		900, 
			0,		90,		4032

del 1
del 1
mul2 1, lBottomHeight
mul2 lRightWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			0,		-1,	32, 
			0,		0,		32, 
			1,	0,		33, 
			0,		0,		900, 
			0,		-90,	4032

del 1
mul2 lLeftWidth, 1

poly2_b{5}	5,      3,      1,      3, MyFillPen, MyFillBgdPen, 
			0,	0,	1,	0,	0,	1,	0, 
			-1,	0,		32, 
			0,		0,		32, 
			0,		-1,	33, 
			0,		0,		900, 
			0,		-90,	4032

del 1
del 1

Hmooslechner
Rockstar
The other Way around - Maybe you get some ideas by downloading (draw it into Archicad) my GDL from bimcomponents and look at the code?

Its not an elliptical shape, but its for the building-site to be able to construct elliptical shapes there with the most simple method form the 2 centerpoints of an ellipse.

https://bimcomponents.com/GSM/Details/20917


Direct elliptical shapes without muly:

Mathematical - you can get a circle by angle, sin and cos.
To "bend" it in y, just an an factor to y

little example: You need parameter "Steps" with an ammount of about 30 to get good visual results



hotspot2 0,0
hotspot2 a, 0
hotspot2 a, b  !! to be able to drag it with the mouse like editable hotspots

dim contpoints[][]  !! making the koordinate-Variables for each step-point 

angle = 360/steps



add2 a/2, b/2  !! to get it in the middle

for i = 1 to steps

		contpoints[1] = cos(angle*i)*a/2  !! calculates each shape-point-coordinate
		contpoints[2] = sin(angle*i)*b/2

		!  circle2 contpoints[1], contpoints[2], 0.02  !!! just marking
		hotspot2 contpoints[1], contpoints[2]


next i


!! now having the coordinates a second time around for the lining


line2 a/2, 0, contpoints[1][1], contpoints[1][2]  !! first line extra..

for i = 1 to steps-1

		line2 contpoints[1], contpoints[2], contpoints[i+1][1], contpoints[i+1][2]

next i


AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Anonymous
Not applicable
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

The reason why I'm asking is because I'm trying to programm a basin with Rounded corners with the ability to adjust the point where it begins to round off. And that for each side

I'm lost

Something like this:
RA , 0 , ST,
A-RA , 0 , ST,
A , RB , ST,
A , B-RB , ST,
A-RA , B , ST,
RA , B , ST,
0 , B-RB , ST,
0 , RB , ST

Any Suggestions?
Of course you can make any shape and have it parametric in GDL! that's why its so much fun.
Just use simple math to chart the points like this:

you need 3 parameters:
hEllipse = height
wEllipse = width
gs_resol = resolution
you may also want to set the origin as parametric in which case you will need the coordinates:
xPOS = x position
yPOS = y position

for n = 0 to 360 step 360/gs_resol
        put xPOS +wEllipse*cos(n), yPOS +hEllipse*sin(n), 1
next n
poly2_b nsp/3, 1+2+4, gs_fill_pen, gs_back_pen,
	get(nsp)
The resolution should depend on the use; if is a small element like plumbing then a resolution of 12 is enough but if its a large design element the you may want to bump the resolution up to around 36, or 72 at most. You should make the resolution accessible in MVO's so it dynamically responds to specific outputs.
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
Kristian wrote:
Of course you can make any shape and have it parametric in GDL! that's why its so much fun.
Just use simple math to chart the points like this:

you need 3 parameters:
hEllipse = height
wEllipse = width
gs_resol = resolution
you may also want to set the origin as parametric in which case you will need the coordinates:
xPOS = x position
yPOS = y position

for n = 0 to 360 step 360/gs_resol
        put xPOS +wEllipse*cos(n), yPOS +hEllipse*sin(n), 1
next n
poly2_b nsp/3, 1+2+4, gs_fill_pen, gs_back_pen,
	get(nsp)
The resolution should depend on the use; if is a small element like plumbing then a resolution of 12 is enough but if its a large design element the you may want to bump the resolution up to around 36, or 72 at most. You should make the resolution accessible in MVO's so it dynamically responds to specific outputs.
Thanks so much for the quick reply!

How can I get more than one NSP into a Poly?

Because at the end I want to use it in 3d with hprism_ So I need to get all 4 corners in one script.


Gs_resol = 72

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



			Poly2_B 8+NSP/3, 7,19,19,
			RA 		, 0 		, 1,
			A-RA 	, 0 		, 1,
			A 		, RB 		, 1,
			A 		, B-RB 		, 1,
			get(NSP),
			A-RA 	, B 		, 1,
			RA 		, B 		, 1,
			0 		, B-RB 		, 1,
			0 		, RB ,		 1

runxel
Legend
Arnaut2604 wrote:
How can I get more than one NSP into a Poly?
There is only "one" NSP 😉
NSP is a special type of global parameter/variable which holds the number of values on the stack.
So just `put` everything you need onto the buffer and retrieve it with `get()`.
"Get" empties the buffer while reading its elements, while "use" will leave the values alone and just read them.

By the way: You can use as many "put" operations as you want. They always append.
The stack in GDL is first-in-first-out.
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
A_ Smith
Expert
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), st
	next n
return
Edit: you must create parameters RA and RB
AC 22, 24 | Win 10