Returns information on the selection, and the selected elements.

    GSErrCode  ACAPI_Selection_Get (
        API_SelectionInfo*     selectionInfo,
        GS::Array<API_Neig>*   selNeigs,
        bool                   onlyEditable,
        bool                   ignorePartialSelection = true,
        API_SelRelativePosID   relativePosToMarquee = API_InsidePartially



[out] The parameters of the current selection. The typeID field of the selectionInfo gives the selection type.
[out] An array containing the GUIDs of the selected elements. Can be nullptr if you are interested in the selection information only.
[in] Tells whether you are interested in editable elements only.
ignorePartialSelection API 18
[in] Retrieves also partial element selection information or the element itself only selected as whole (for legacy compatibility reasons, the default value of this parameter is true, meaning partial selection is ignored). This parameter is ignored in case of marquee based selection.
relativePosToMarquee API 18
[in] Retrieves elements relative to marquee (for legacy compatibility reasons, the default value of this parameter is API_InsidePartially, meaning only those elements will be returned which have an intersection with the marquee area). This parameter is ignored in case of individually selected elements.


Return Values

The function has completed with success.
There is no open project.
There is no selection. Note that this is not a real error!

For other common API errors see the API Errors document.



This function is used to get information about the current selection and to retrieve the selected elements. The information is returned in the selectionInfo parameter.

If individual elements are selected the API_SelElems identifier is returned. The number of the selected and selected and editable elements are also returned. In case of marquee based selection, the function gives back the actual polygon of the current selection in the API_SelectionInfo structure; don’t forget to dispose this handle.

The API_SelEmpty identifier in the typeID field of the selectionInfo parameter means that no selection is actually used in Archicad.

In case of individually selected elements, Archicad returns all the elements which are selected. In the case of marquee based selection, only those will be returned which match the position criteria defined by relativePosToMarquee.



// Collect in inds the guids of the dimensions to work with
static GSErrCode SelectDimensions (GS::Array<API_Guid>& inds)

    GSErrCode            err;
    API_SelectionInfo    selectionInfo;
    API_Elem_Head        tElemHead;
    GS::Array<API_Neig>  selNeigs;

    err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, true);
    BMKillHandle ((GSHandle *) &selectionInfo.marquee.coords);
    if (err == APIERR_NOSEL)
        err = NoError;

    if (selectionInfo.typeID != API_SelEmpty) {
        // collect indexes of selected dimensions
        UInt32 nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig);
        for (const API_Neig& selNeig : selNeigs) {
            tElemHead.typeID = Neig_To_ElemID (selNeig.neigID);
            if (tElemHead.typeID != API_DimensionID)

            if (!ACAPI_Element_Filter (selNeig.guid, APIFilt_IsEditable))

            tElemHead.guid = selNeig.guid;
            if (ACAPI_Element_GetHeader (&tElemHead) != NoError)

            // Add dimension to the array
            inds.Push (tElemHead.guid);

    return err;
}   // SelectDimensions



Version: API 4.1 or later
Header: ACAPinc.h


See Also

API_Neig, API_SelectionInfo, API_SelRelativePosID,
Selection Manager, API Functions