We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-05-30 08:32 AM - last edited on 2024-06-06 04:57 PM by Laszlo Nagy
What is API_Neig?
I encountered the term API_Neig in the MEP Test example, where it is used for selecting an MEP element. Can someone explain what API_Neig represents and how it is used in the context of MEP elements?
Extracting Polyline Information for All Routing Elements in the Model
I want to extract the Polyline information for all Routing Elements from the entire model, not just from a specific selection. Here’s the workflow I’m using:
However, I’m unable to get any coordinates using this method. The same workflow successfully retrieves the polyline when a specific routing element is selected. What could be the issue with extracting polyline data for all routing elements in the model?
2024-06-03 02:05 PM
Are you confident that the elements you're inspecting should have a polyline? I haven't tried myself yet, but I assume not all MEP elements have one.
If you haven't tried already I suggest building and running the API example project "MEP_Test". It includes a function WriteRoutingElementDetails which echoes what you're trying to do. If it works, we can try to work out what the difference is. If it doesn't work, I suspect it's a problem with the MEP elements you are trying to inspect.
2024-06-03 02:42 PM
Initial Success with MEP_Test:
MEP_Test Functionality:
Objective:
void ExtractAllRoutingElements() {
GS::Array<API_Guid> elementGuids;
ACAPI_Element_GetElemList(API_ZombieElemID, &elementGuids);
for (const API_Guid& guid : elementGuids) {
API_Element element = {};
element.header.guid = guid;
if (ACAPI_Element_Get(&element) == NoError) {
// Check if the element is a routing element
if (element.header.typeID == API_ExternalElemID &&
(IsBranch(element.header.type.classID) ||
IsAccessory(element.header.type.classID) ||
IsEquipment(element.header.type.classID) ||
IsTerminal(element.header.type.classID) ||
IsFitting(element.header.type.classID) ||
IsFlexibleSegment(element.header.type.classID) ||
IsRoutingElement(element.header.type.classID))) {
// Process the routing element
Adapter::UniqueID uniqueId(guid);
WriteRoutingElementDetails(uniqueId);
}
}
}
}
void WriteRoutingElementDetails(Adapter::UniqueID &uniqueId) {
try {
ACAPI::Result<RoutingElement> routingElementResult = RoutingElement::Get(uniqueId);
if (routingElementResult.IsErr()) {
const auto& error = routingElementResult.UnwrapErr();
ACAPI_WriteReport(error.text.c_str(), false);
return;
}
Reporter routingElementReporter;
std::vector<API_Coord3D> polyline = routingElementResult->GetPolyLine();
if (polyline.empty()) {
ACAPI_WriteReport("Polyline is empty", false);
} else {
routingElementReporter.Add("Polyline of the routing element:");
routingElementReporter.SetTabCount(1);
for (const API_Coord3D& node : polyline) {
routingElementReporter.Add(node);
}
routingElementReporter.Add("This is new Tab");
routingElementReporter.Write();
}
polyline.clear();
} catch (const std::exception& e) {
ACAPI_WriteReport(std::string(e.what()).c_str(), false);
} catch (...) {
ACAPI_WriteReport("Unknown exception in WriteRoutingElementDetails", false);
}
}
Implementation:
ExtractAllRoutingElements Function:
WriteRoutingElementDetails Function:
2024-06-03 02:50 PM
The function WriteRoutingElementDetails in the "MEP_Test" project only takes the guid to an element as a parameter, which means it should work the same way irrespective of being selected or not. Have you tried a copy/paste of that function to your code to see if it still works when the element guids have not come from a selection?
2024-06-03 03:06 PM
I tried copy pasting the same in my code ( writeRoutingElementDetails comes from MEP_Test Example ). It still doesn't work.
2024-06-03 03:10 PM
Are the element guids the same in both cases?