Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I script a parametric ellipsoidal shape?

JGoode
Enthusiast
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 17, 19, 21 and 23
Windows 8
23 REPLIES 23

Braza
Newcomer
JGoode wrote:
CAN I CREATE THIS...?
I presume, by the fact that you can enter different dimensions on each parameter, that your circle could end being a double eccentric ellipse, right?
Could you elaborate on what the object is for?
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

Joachim Suehlo
Advocate
If you want to put in the dimensions in the floor plan, this is only possible with moveable Hotpots, which also have a numerical input field; but I think these input fields are not placed in the center and are only visible when you click on the hotspot.
Joachim Suehlo . AC12-25 . MAC OSX 10.15 . WIN10

Braza
Newcomer
Absolutely right Joachim.
I didn't get the parameter direct input value part.
It looks like some Revit user wish. Right JGoode?
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

JGoode
Enthusiast
Sorry, the dimensions would be entered on the interface and I'd potentially have dynamic hotspots at the top, bottom and sides of the 'circle' that would end up not being a circle. The use of this would be for our tree object where in plan they can be a funny shape and therefore we want to reflect that and have a bit more control instead of a just a circle!

The query was more so about creating the shape than it was inputting the dimensions!

I hope this makes a little more sense now, I was a little unsure as to how to explain it to begin with!

Braza, to answer you question... I am not a Revit user! Just trying to figure out if ArchiCAD has the functionality in GDL to do something a little more outside the box.
ArchiCAD 17, 19, 21 and 23
Windows 8

Braza
Newcomer
JGoode wrote:
Braza, to answer you question... I am not a Revit user!
Congratulations! This is a good start.
JGoode wrote:
Sorry, the dimensions would be entered on the interface
Do you mean the User Interface inside Object Settings?
If so... This is perfectly doable.
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

JGoode
Enthusiast
I did mean that but I'm very happy with creating the User Interface but it's the creating the actual geometry I'm struggling with as I want it to be a continuous arc rather than a point like a regular prism with curved sides would create. Does this make sense?
ArchiCAD 17, 19, 21 and 23
Windows 8

Braza
Newcomer
Try this in your 2d script.
HOTSPOT2 0, 0
mul2 lRightWidth, 1
ARC2 0, 0, 0.5, -90, 90
del 1

mul2 lLeftWidth, 1
ARC2 0, 0, 0.5, 90, 270
del 1
Hope this helps.
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

Braza
Newcomer
Ok. Forgot to add the Height parameters. Here it is:
HOTSPOT2 0, 0

mul2 1, lTopHeight
mul2 lRightWidth, 1
ARC2 0, 0, 0.5, 0, 90
del 1

mul2 lLeftWidth, 1
ARC2 0, 0, 0.5, 90, 180
del 1
del 1

mul2 1, lBottomHeight
mul2 lRightWidth, 1
ARC2 0, 0, 0.5, 270, 360
del 1

mul2 lLeftWidth, 1
ARC2 0, 0, 0.5, 180, 270
del 1
del 1
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

JGoode
Enthusiast
Oh, that's brilliant! Thank you so much!

Here's another step that I'm really not so confident about, is there anyway to create that with a fill?

Many thanks,
ArchiCAD 17, 19, 21 and 23
Windows 8

Peter Baksa
Graphisoft
Graphisoft
Yes, use poly2_ with additional status codes.
Péter Baksa
Software Engineer, Library as a Platform
GRAPHISOFT SE, Budapest

Braza
Newcomer
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
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

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

Braza
Newcomer
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

Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

Hmooslechner
Expert
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-AC25EduAut, PC-Win10, MacbookAirM1

Arnaut2604
Newcomer
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

Arnaut2604
Newcomer
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
Mentor
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.
AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

A_ Smith
Contributor
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

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!