We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Problems retrieving 3D objects

Anonymous
Not applicable
Hey everyone,

i implemented a KD-Tree structure in an Archicad 21 Addon to sort all the 3D elements in the 3D-model. But im having a little trouble feeding the right information to it:

As far as i have seen from the example there are basically two ways i could do it.

1. via ACAPI_Element_GetElemList and using the ACAPI_​Element_​Get3DInfo which is nice since it allready provides bounding box information for example.
Problems: The APIFilt_In3D doesn't work for API_ZombieElemID elements. So i used all the relevant types like API_WallID and so on. But even there the APIFilt_In3D seemes to not work correctly since when i use it instead of the normal APIFilt_None no elements are returned. With the APIFilt_None i get the elements i want plus some additional elements that don't appear in 3D in the test scene so i guess they aren't in 3D. Am i using APIFilt_In3D wrong?

example code:

GS::Array<API_Guid> elemGuids;

// store all the 3D element types in an array
 GS::Array<API_ElemTypeID> types = {API_WallID, API_ColumnID, API_BeamID, API_WindowID, API_DoorID, API_ObjectID, API_LampID, API_SlabID, API_RoofID, API_MeshID, API_ShellID, API_CurtainWallID, API_MorphID};
    
//push all 3d elements from all types to elemGuids array
for (int i=0; i<types.GetSize();i++){
    WriteReport("Type %i", types);
    GS::Array<API_Guid> temp_elems;
    ACAPI_Element_GetElemList(types, &temp_elems, APIFilt_In3D);
    WriteReport("Number of objects %i" , temp_elems.GetSize());
    for (int j=0; j<temp_elems.GetSize();j++){
        elemGuids.Push(temp_elems);
    }
}

2. via the body IDs as descibed in the 3D_Test example and the ACAPI_3D_GetComponent
Problem: I don't know how to get the get the link back to the Archicad elements (for example API_GUID objects) from the 3D components.

So my question baiscally is how to link the information from the API_​Element to the 3D components in both ways. From API_​Element to the 3D_component seems to work over the ACAPI_​Element_​Get3DInfo since it has the first and last component stored but is there a way to do it the other way arround too?

I would very much appreciate any help with this!

Edit: The additional elements of type API_ObjectID describe in 1. seem to be labels of the windows.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
dfintha
Graphisoft Alumni
Graphisoft Alumni
Hello,

I recommend using your first choice.
I've managed to reproduce the issue you have. Currently, you need to have an open 3D tab, where the elements you want to work with are visible. In my case, with only the floor plan opened, I also got zero results, but after opening the general perspective view, the function managed to find all visible 3D elements.
Beware, elements on a hidden layer are not considered visible.
I'll file a ticket with this issue right away.

Best regards,
Dénes

View solution in original post

3 REPLIES 3
Solution
dfintha
Graphisoft Alumni
Graphisoft Alumni
Hello,

I recommend using your first choice.
I've managed to reproduce the issue you have. Currently, you need to have an open 3D tab, where the elements you want to work with are visible. In my case, with only the floor plan opened, I also got zero results, but after opening the general perspective view, the function managed to find all visible 3D elements.
Beware, elements on a hidden layer are not considered visible.
I'll file a ticket with this issue right away.

Best regards,
Dénes
Anonymous
Not applicable
Hey Dénes, thanks for the information on the topic! This helped me solve my issues.
Ralph Wessel
Mentor
We use one of 2 paths depending on the context:
1) ACAPI_Element_Get3DInfo: When we're iterating through elements that aren't necessarily already in a 3D view but need 3D body info.

2) ModelerAPI: When we're iterating through elements in a 3D scene using, for example, ModelerAPI::Model::GetElement. This gets also gets all the relevant body info and appears to have a method to get the original element guid, i.e. ModelerAPI::Element::GetElemGuid (but we don't currently use it).
Ralph Wessel BArch
Software Engineer Speckle Systems