License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…
3 weeks ago
Hi I am trying to get object geometries using ArchiCAD API and convert them to .obj files but I couldn't get the openings on the walls. I only got whole geometry of a wall even if it have windows or doors placed on it. What I am missing? Any help is appreciated.
for (Int32 ibody = info3D.fbody; ibody <= info3D.lbody; ibody++) {
API_Component3D component = {};
component.header.typeID = API_BodyID;
component.header.index = ibody;
err = ACAPI_ModelAccess_GetComponent(&component);
if (err != NoError)
continue;
nVert = component.body.nVert;
nEdge = component.body.nEdge;
nPgon = component.body.nPgon;
// Collect vertices
std::vector<API_VertType> verts(nVert + 1);
for (j = 1; j <= nVert; j++) {
component.header.typeID = API_VertID;
component.header.index = j;
err = ACAPI_ModelAccess_GetComponent(&component);
if (err == NoError) {
verts[j] = component.vert;
char buf[128];
snprintf(buf, sizeof(buf), "v %f %f %f\n", component.vert.x, component.vert.y, component.vert.z);
objContent += buf;
}
}
// Collect edges
std::vector<API_EdgeType> edges(nEdge + 1);
for (j = 1; j <= nEdge; j++) {
component.header.typeID = API_EdgeID;
component.header.index = j;
err = ACAPI_ModelAccess_GetComponent(&component);
if (err == NoError) {
edges[j] = component.edge;
}
}
// Write faces
for (j = 1; j <= nPgon; j++) {
component.header.typeID = API_PgonID;
component.header.index = j;
err = ACAPI_ModelAccess_GetComponent(&component);
if (err != NoError)
continue;
API_PgonType p = component.pgon;
// Collect all contours (outer + holes)
std::vector<std::vector<int>> contours;
std::vector<int> currentContour;
for (Int32 pedgIdx = p.fpedg; pedgIdx <= p.lpedg; ++pedgIdx) {
component.header.typeID = API_PedgID;
component.header.index = pedgIdx;
err = ACAPI_ModelAccess_GetComponent(&component);
if (err != NoError) break;
API_PedgType pedg = component.pedg;
if (pedg.pedg == 0) {
// End of current contour, start a new one
if (!currentContour.empty())
contours.push_back(currentContour);
currentContour.clear();
continue;
}
Int32 edgeIdx = abs(pedg.pedg);
if (edgeIdx < 1 || edgeIdx > nEdge) continue;
const API_EdgeType& edge = edges[edgeIdx];
int vIdx = (pedg.pedg > 0) ? edge.vert1 : edge.vert2;
currentContour.push_back(vertexOffset + vIdx);
}
if (!currentContour.empty())
contours.push_back(currentContour);
// Only export the outer contour (first one) as a face
if (!contours.empty() && contours[0].size() >= 3) {
const std::vector<int>& faceIndices = contours[0];
for (size_t k = 1; k + 1 < faceIndices.size(); ++k) {
char buf[128];
snprintf(buf, sizeof(buf), "f %d %d %d\n", faceIndices[0], faceIndices[k], faceIndices[k + 1]);
objContent += buf;
}
}
}
vertexOffset += nVert;
}
2 weeks ago
- last edited
2 weeks ago
by
Laszlo Nagy
Hi, I'd suggest you to try pass the window/door guid and call the following command:
HTH.
elemHead.guid = window_guid;
err = ACAPI_ModelAccess_Get3DInfo(elemHead, &info3D);
if (err) return;
for (Int32 i = info3D.fbody; i <= info3D.lbody; i++) {
API_Component3D component{};
component.header.typeID = API_BodyID;
component.header.index = i;
err = ACAPI_ModelAccess_GetComponent(&component);
...
2 weeks ago
Yes I am also putting window/door guids into that function and it gives me complete geometry of the object. However I cannot get the openings on the walls that have windows on it. I have a simple project with a wall and a windows on it. I can get the wall and windows using guids and Model_Access_API. But I cannot see the opening on the wall where the window should be. Is there a way to get that?
a week ago
Hi, Maybe I'm not fully understand what you meant the opening. You cannot get the opening geometry only as it's represented by wall. I mean if you get the wall geometry, than you can a piece of wall with a hole (opening) geometry.
HTH.
Wednesday
I expect the wall should have a hole in its geometry representation where the window placed. But maybe I am thinking wrong.