ACAPI_​Element_​Delete

Deletes a number of elements.

    GSErrCode  ACAPI_Element_Delete (
        const GS::Array<API_Guid>& elemGuids
    );

 

Parameters

elemGuids
[in] This parameter identifies the elements to be deleted.

 

Return Values

NoError
The function has completed with success.
APIERR_BADDATABASE
The current database is not proper for the operation.
APIERR_MEMFULL
not enough memory to complete the operation
APIERR_NOTMINE
The operation attempted to delete an element that belongs to another user. Likely to occur in teamwork mode.
 

For other common API errors see the API Errors document.

 

Remarks

You can use this function to delete elements identified by elemGuids. To delete the selected elements use ACAPI_Element_DeleteSelected function.

In the case there is at least one element which are not allowed to delete for some reason, the whole command is terminated. Such cases can be:

  • it is locked,
  • it is on a locked layer,
  • it is part of a group, and suspend group is OFF
  • it is a subelement of a composite element (Curtain Wall, Stair, or Railing)
  • it is not in the users workspace, etc.

The following notes are absolutely important:

  • the list of target elements will be automatically extended by the other group members; if there are a group member in the set, and suspend group is OFF
  • all the linked elements will be deleted; associative labels, dimensions etc.

Note that this function is working on the Section/Elevation databases also, which may have references to the plan database; they called virtual symbols identified by the API_SectElemID element type. From Archicad 6.50 R2/V2 these elements can be deleted directly from the section database, with the limitation that the section window must be the front window.

 

Example


GSErrCode   Do_DeleteSelectedWalls (void)
{
    return ACAPI_CallUndoableCommand ("Delete selected walls",
        [&] () -> GSErrCode {
            GSErrCode            err;
            API_SelectionInfo    selectionInfo;
            GS::Array<API_Neig>  selNeigs;

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

            GS::Array<API_Guid> wallGuids;
            for (const API_Neig& neig : selNeigs) {
                API_Elem_Head head = {};
                head.guid = neig.guid;
                if (ACAPI_Element_GetHeader (&head) == NoError && head.typeID == API_WallID)
                    wallGuids.Push (head.guid);
            }

            return ACAPI_Element_Delete (wallGuids);
        });
}

GSErrCode    Do_DeleteSelectedElements (void)
{
    return ACAPI_CallUndoableCommand ("Delete selected elements",
        [&] () -> GSErrCode {
            GSErrCode   err = ACAPI_Element_DeleteSelected ();
            if (err != NoError)
                ErrorBeep ("ACAPI_Element_DeleteSelected", err);

            return err;
        });
}

 

Requirements

Version: API 1.3 or later
Header: ACAPinc.h

 

See Also

API_Elem_Head, API_Guid,
Element Manager, ACAPI_Element_DeleteSelected, API Functions