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.

Morph's vertices, coordinates

Anonymous
Not applicable
Hey,

How is it possible to get the vertices of a Morph in AC17? Mostly I read the data through the memo, but this time it doesn't seem to work.

Thanks,
Andor
1 REPLY 1
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi Andor,

please try at first with ACAPI_Element_Get3DInfo function.
Example code:
// ----------------------------------------------------------------------------- 
// Dump a vertices of a body (VERT) 
// ----------------------------------------------------------------------------- 
 
static void		DumpVertices (Int32 ibody, const API_Coord& dbOffset) 
{ 
	API_Component3D 	component; 
	Int32				j, nVert; 
	API_Tranmat			tm; 
	GSErrCode			err; 
 
	WriteReport ("BODY #%d", ibody); 
 
	BNZeroMemory (&component, sizeof (component)); 
 
	component.header.typeID = API_BodyID; 
	component.header.index  = ibody; 
	err = ACAPI_3D_GetComponent (&component); 
	if (err != NoError) { 
		WriteReport ("    ERROR"); 
		return; 
	} 
 
	nVert = component.body.nVert; 
	tm = component.body.tranmat; 
 
	WriteReport ("  VERTs"); 
	for (j = 1; j <= nVert; j++) { 
		component.header.typeID = API_VertID; 
		component.header.index  = j; 
		err = ACAPI_3D_GetComponent (&component); 
		if (err == NoError) { 
			API_Coord3D	trCoord;	// world coordinates 
			trCoord.x = tm.tmx[0]*component.vert.x + tm.tmx[1]*component.vert.y + tm.tmx[2]*component.vert.z + tm.tmx[3]; 
			trCoord.y = tm.tmx[4]*component.vert.x + tm.tmx[5]*component.vert.y + tm.tmx[6]*component.vert.z + tm.tmx[7]; 
			trCoord.z = tm.tmx[8]*component.vert.x + tm.tmx[9]*component.vert.y + tm.tmx[10]*component.vert.z + tm.tmx[11]; 
			trCoord.x += dbOffset.x; 
			trCoord.y += dbOffset.y; 
			WriteReport ("    [%2d]  (%lf, %lf, %lf)", 
						 j, 
						 trCoord.x, trCoord.y, trCoord.z); 
		} 
	} 
	return; 
}		// DumpVertices 
 
//------------------------------------------------------------------------------------------ 
 
err = ACAPI_Element_Get3DInfo (elemHead, &info3D); 
if (err == APIERR_BADID) { 
	WriteReport_Alert ("This element does not have 3D information."); 
	return; 
} 
if (err != NoError) { 
	ErrorBeep ("Error in ACAPI_Element_Get3DInfo", err); 
	return; 
} 
 
for (Int32 ibody = info3D.fbody; ibody <= info3D.lbody; ibody++) 
	DumpVertices (ibody, dbOffset);


You can find a good example in the 3D_Test example Add-On.

Regards,
Tibor
Learn and get certified!