cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

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

Extracting the Polyline data for MEP Elements from the Model

Amit Tiwari
Contributor

 

  • 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:

  • getElementList: Retrieve all elements.
  • Filter by TypeID: Check if it’s an MEP Element.
  • Check if Routing Element: Confirm if it’s a routing element.
  • get Routing Element for this guid: Retrieve the routing element.
  • extract the Polyline using getPolyline(): Attempt to get the polyline.

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?    

 

CADDeveloper_0-1717050646993.png

 

CADDeveloper_1-1717050684496.png

 

 

14 REPLIES 14
Amit Tiwari
Contributor

@Viktor Kindly help

 

Ralph Wessel
Mentor

API_Neig is primarily concerned with element selection. It carries element identifiers so the element can be loaded, e.g. with ACAPI_Element_Get, but also contains information about how/where the element was selected, e.g. if the user selected a hole in a slab, the API_Neig structure would identify that a slab was selected and carry enough data to identify the selected hole. This means that any add-on looking at the user selection will use this structure, including MEP add-ons.

Ralph Wessel BArch
Software Engineer Speckle Systems
Ralph Wessel
Mentor

If you want to find all elements of some type rather than just the selected elements, take a look at ACAPI_Element_GetElemList. This allows you to retrieve an array of elements from anywhere (whether selected or not).

Ralph Wessel BArch
Software Engineer Speckle Systems
Amit Tiwari
Contributor

Hi Ralph,

Thank you for your previous response. I'm currently working on extracting polyline data for all MEP elements in my model. Here's the workflow I'm implementing:

  1. Retrieve All Elements:

    • I use ACAPI_Element_GetElemList to get a comprehensive list of all elements in the database.
  2. Filter for MEP Elements:

    • From this list, I filter out the elements that are of the MEP type.
  3. Extract Polyline Data from Routing Elements:

    • For each MEP element identified as a RoutingElement, I extract the polyline data.

Although I've implemented this workflow, I'm not getting any results. Can you please help me identify what might be going wrong or suggest any improvements?

Thank you!

Can you clarify what you mean by "not getting any results"? At what point in the 3 steps you described does the process seem to fail? For example, is the process correctly finding MEP elements? If so, how are you trying to get the required information from them (and what happens)?

Ralph Wessel BArch
Software Engineer Speckle Systems

In the third step, I am not able to obtain any polyline data; First two steps succeed. When I use the following line

ACAPI::Result<RoutingElement> routingElementResult = RoutingElement::Get (uniquId);
 
 
if (routingElementResult.IsErr()) {
const auto& error = routingElementResult.UnwrapErr();
ACAPI_WriteReport(error.text.c_str(), false);
return;
}
 
Reporter routingElementReporter;
std::vector<API_Coord3D> polyline = {};
polyline  =routingElementResult->GetPolyLine();     --> this line doesn't populate teh polyline with coordinates data