ACAPI_​Element_​Merge_​Elements

Merge elements given in the array.

    GSErrCode  ACAPI_Element_Merge_Elements (
        const GS::Array<API_Guid>&     guid_ElementsToMerge
    );

 

Parameters

guid_ElementsToMerge
[in] Array of GUIDs of the elements to merge.

 

Return Values

NoError
The function has completed with success.
APIERR_NEEDSUNDOSCOPE
The function must be undoable, it wasn’t called from an undoable command scope.
APIERR_BADDATABASE, APIERR_NOTMINE
The function cannot operate on the current database.
APIERR_BADINDEX
One or more of the passed IDs are invalid.
APIERR_BADPARS
Invalid value passed in the guid_ElementsToMerge parameter.
APIERR_BADELEMENTTYPE
There is element in the array, which is not construction element type.

For other common API errors see the API Errors document.

 

Remarks

This function merges elements given in the array.

 

Example


void Do_Merge_Elements (void)
{
    API_SelectionInfo   selectionInfo;
    API_Neig**          selNeig;
    API_Element         element;

    // Get selection
    GSErrCode err = ACAPI_Selection_Get (&selectionInfo, &selNeig, true);
    if (err != NoError && err != APIERR_NOSEL) {
        ErrorBeep ("ACAPI_Selection_GetInfo", err);
        return;
    }
    BMKillHandle ((GSHandle *) &selectionInfo.marquee.coords);

    GS::Array<API_Guid> guid_ElementsToMerge;

    for (Int32 i = 0; i < selectionInfo.sel_nElemEdit; i++) {
        // Get selected element
        BNZeroMemory (&element, sizeof(element));
        element.header.guid = (*selNeig)[i].guid;
        if (ACAPI_Element_Get (&element) != NoError)
            continue;
        API_ElemTypeID  tmpTypeID = element.header.typeID;
        API_Guid        tmpGuid = element.header.guid;
        if (tmpTypeID == API_SectElemID) {
            tmpTypeID = element.sectElem.parentID;
            tmpGuid = element.sectElem.parentGuid;
        }

        guid_ElementsToMerge.Push (tmpGuid);
    }

    BMKillHandle ((GSHandle *) &selNeig);

    if (!guid_ElementsToMerge.IsEmpty ()) {
        GSErrCode err = ACAPI_Element_Merge_Elements (guid_ElementsToMerge);
        if (err != NoError) {
            if (err == APIERR_NO3D)
                WriteReport_Alert ("Elements To Merge can be construction elements only.");
            else
                WriteReport_Alert ("ACAPI_Element_Merge_Elements failed: %d", err);
        }
    } else {
        WriteReport_Alert ("There are no selected construction elements!\n");
    }

    return;
}

 

Requirements

Version: API 18 or later
Header: ACAPinc.h

 

See Also

ACAPI_Element_Merge_Remove
ACAPI_Element_Merge_GetMergedElements
API Functions