BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

[newbie] stepping through the vertices of a polygon

stefan
Expert
My Radiance exporter is slowly getting born...

I am failing to step through the vertices of a polygon.
I am able to get access to the body of the 3D-objects.

The 3D-Test example shows how to step through all the vertices of the body and through all the edges, but to have something usable, I have to do this polygon by polygon.

I can get the amount of vertices, edges & polygons (I left out the error code):
API_Component3D 	component;
long		j, nVertices, nEdges, nPolygons;
GSErrCode	err;
BNZeroMemory (&component, sizeof (component));
component.header.typeID = API_BodyID;
component.header.index  = ibody;
ACAPI_3D_GetComponent (&component);
nVertices	= component.body.nVert;
nEdges		= component.body.nEdge;
nPolygons	= component.body.nPgon;
and then I step through all polygons:
for (j = 1; j <= nPolygons; j++)
{
	component.header.typeID = API_PgonID;
	component.header.index = j;
	ACAPI_3D_GetComponent(&component);
	long firstEdge, lastEdge;
	firstEdge = component.pgon.fpedg;
	lastEdge  = component.pgon.lpedg;
	// Walk through the edges
	for (long e = firstEdge; e < lastEdge; e++)
	{
		component.header.typeID = API_PedgID;
		component.header.index = e;
		ACAPI_3D_GetComponent(&component);
		// get the edge
		API_PedgType &edge = ??????????
	}
}
I'm not sure if I'm doing this correct, but I did this in about the same way as stepping through the other elements. So how do I get the list of vertices that is used in one particular polygon?
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad27/Revit2023/Rhino8/Unity/Solibri/Zoom
MBP2023:14"M2MAX/Sonoma+Win11
Archicad-user since 1998
my Archicad Book
13 REPLIES 13
Karl Ottenstein
Moderator
Ralph wrote:
Oleg is correct regarding the efficiencies of the internal implementation. I also agree with your observation regarding a wrapper class - I have implemented classes for this very purpose. It was more time-consuming to write up-front, but the long-term gain through ease of use has made it worthwhile. Very efficient too. The other main benefit is that we won't suffer so much if the API for this data changes - the differences should be absorbed by the wrapper and not everything based on it.
Well done, Ralph! Exactly the point of abstraction... and I wonder (not that we'll ever know) if GS themselves do this with their own add-ons, but just don't make the wrappers available to us...

Really appreciate your and Oleg's participation here as our resident experts.

Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Akos Somorjai
Graphisoft
Graphisoft
Karl wrote:
and I wonder (not that we'll ever know) if GS themselves do this with their own add-ons, but just don't make the wrappers available to us...

Karl
Some parts of GS do, but the main add-on development doesn't. This is due to a lot of legacy code and code from external developers we have here, and the lack of time to modernize/unify those.

Just my 2€,

Akos
Karl Ottenstein
Moderator
Akos wrote:
Some parts of GS do, but the main add-on development doesn't. This is due to a lot of legacy code and code from external developers we have here, and the lack of time to modernize/unify those.
Good to see you here, Akos! I would say "welcome", but Djordje would tell me that I can't welcome you to your own forum...but welcome, anyway. 😉

The situation sounds not so unusual ...

Best regards,
Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Akos Somorjai
Graphisoft
Graphisoft
Karl wrote:
Good to see you here, Akos! I would say "welcome", but Djordje would tell me that I can't welcome you to your own forum...but welcome, anyway. 😉

The situation sounds not so unusual ...

Best regards,
Karl
Thanks for that. It's good to see that the forum is in good hands!

Akos
Learn and get certified!