Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Extract Slab surface from a Slab accessory object

Mario Sacco
Expert
I'm creating a Slab accessory object.
I want to insert in the parameters, the surface of the slab associated to the object, to use it for list and schedules.
Is there a way to extract the slab surface in the accessory object?

In the object I have the coordinate of the point of the perimeter and also the holes; but I think it's very complex elaborate the surface of a polyline from its point.
MacBook M1 Max 64GB- OS X 12.2.1 - Archicad 27
https://www.archiradar.it/en/
8 REPLIES 8
Hmooslechner
Moderator
I was stumbeling over the same issue and some others at developing on my new tiling-object.

it could be possible to export the polygon-coordinate-list to the implemented polygonoperations-plugin and to get these informations that way, but i am far away to be able to use this addon.

I want to get the number of tiling-plates which are inner the boundaries of the polygone-fence - and this should be possible also with the polyoperatio-addon.

But its programmed to complex for my simple mind..


I remember an item in the GDL-Book of the australian office - where are listend some of these topics - i read about it some years ago and these days, i had no aplication for these things but now... I must reread it and i'll tell the results here..

i Think it was this book: https://www.amazon.com/GDL-Handbook-Comprehensive-Creating-Powerful/dp/0473148609/ref=sr_1_4?ie=UTF8&qid=1470383057&sr=8-4&keywords=Archicad+GDL


Here its what i am working on sometimes: Just turn off the german sound..

https://www.youtube.com/watch?v=_K6i7YK0yow
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Mario Sacco
Expert
I used this method: it's in italian.
It works fine.
http://it.wikihow.com/Calcolare-l'Area-di-un-Poligono
MacBook M1 Max 64GB- OS X 12.2.1 - Archicad 27
https://www.archiradar.it/en/
Hmooslechner
Moderator
That really looks easy - two loops over the coordinate-list should do the job. Thanks!
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Hmooslechner
Moderator
How about calculating the geometric focus? This would be useful for eg. to place text automaticly there.

The normal average of the surrounding coordinats does not the job. If on one end are used more Points, the average point moves more there. So the geometric focus is much better.

Is there a similar way like the above mentioned calculation to do this?
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Hmooslechner
Moderator
Also very important would be a simple test, if a point is in the boundaries of an Polygon or not.

Here is my code for the Area of the polygone and it seems to work:

(The polygone is given in x[1] to x[points] and y[1] to y[points])
	

	SumA1 = 0   !! initialize.
	
		FOR i=1 to points
	
	
		  if i < points then A1 = x*y[i+1]
		  if i = points then A1 = x*y[1]
	
			SumA1 = SumA1 + A1
	
		NEXT i
	
	
	SumA2 = 0
	
		FOR i=1 to points
	
	
		  if i = 1 then A2 = x*y[points]
		  if i > 1 and i < points then A2 = x*y[i-1]
	
			SumA2 = SumA2 + A2
	
		NEXT i
	
	!Text2 1.2, 1.2, "A1:     " + str(SumA1, 4,2) + "m2"
	!Text2 1.2, 1.1, "A2:     " + str(SumA2, 4,2) + "m2"
	
	Summe = (SumA1 - SumA2)/2  !!! Calculate


	Text2 0, 0, "Area: " + str(Summe, 4,2) + "m2"

AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Hmooslechner
Moderator
There is an implemented macro in the Archicad-library: documented here:

www.graphisoft.com/ftp/techsupport/documentation/developer_docs/BasicLibraryDoc/15/Window-Macros/PolygonOperations.html

with this - it should be possible to calculate such things like If a point is inside or the Area and such things.

But i get mad by trying to implement this into my scripts.

I simply took the "old" polygone -script from esteban ramos - becaues i am so used to it.. and made an additional point for testpurpose..



!!This is at the end of the code after the polygone code


for i = 1 to points-1  				!! give the points from the Code from Esteban Ramos to the stack

	put x, y


next i


call "PolygonOperations", 			!! http://www.graphisoft.com/ftp/techsupport/documentation/developer_docs/BasicLibraryDoc/15/Window-Macros/PolygonOperations.html
    parameters  opcode      = 2,  	!! Point inside Polygone
                srcPolygon1 = 2,  	!! Input from the GDL stack
                result      = 2,  	!! 1 = Output to a parameter (returned_parameter) 2 = to stack
				pntX = Tx,			!! Eingabe Koordinaten
				pntY = Ty			!! Eingabe Koordinaten

Ret = get(1)





if Ret = 1 then 
	circle2 Tx, Ty, 0.3
	Text2  Tx, Ty, "inner"
endif

if ret = 2 then 
	circle2 Tx, Ty, 0.3
	Text2  Tx, Ty, "outer"
endif

It works - but inconsistent and with obviosly errors - i am notable to locate..
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Hmooslechner
Moderator
I found my mistake now:

In the stack are not only the X and Y - coordinates to deliver. An additional value has to be there - for Using it later in Poly2 and similar commands.


!!This is at the end of the code after the polygone code


for i = 1 to points-1  				!! give the points from the Code from Esteban Ramos to the stack

	put x, y, put 1  !!!!  HERE 3 Values has to be inserted !!!!


next i


call "PolygonOperations", 			!! http://www.graphisoft.com/ftp/techsupport/documentation/developer_docs/BasicLibraryDoc/15/Window-Macros/PolygonOperations.html
    parameters  opcode      = 2,  	!! Point inside Polygone
                srcPolygon1 = 2,  	!! Input from the GDL stack
                result      = 2,  	!! 1 = Output to a parameter (returned_parameter) 2 = to stack
				pntX = Tx,			!! Eingabe Koordinaten
				pntY = Ty			!! Eingabe Koordinaten

Ret = get(1)





if Ret = 1 then 
	circle2 Tx, Ty, 0.3
	Text2  Tx, Ty, "inner"
endif

if ret = 2 then 
	circle2 Tx, Ty, 0.3
	Text2  Tx, Ty, "outer"
endif
AC5.5-AC27EduAut, PC-Win10, MacbookAirM1, MacbookM1Max, Win-I7+Nvidia
Im glad you posted this, should make for a much cleaner breakline in my stairs! Thank you!