ACAPI_​Element_​DeleteSelected

Deletes the selected elements.

    GSErrCode  ACAPI_Element_DeleteSelected ();

 

Parameters

 

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 selected elements. To delete specific elements use ACAPI_Element_Delete 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_DeleteSelectedElements (void)
{
    return ACAPI_CallUndoableCommand ("Delete selected elements",
        [&] () -> GSErrCode {
            GSErrCode   err = ACAPI_Element_DeleteSelected ();
            if (err != NoError)
                ErrorBeep ("ACAPI_Element_DeleteSelected", err);

            return err;
        });
}

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.type == API_WallID)
                    wallGuids.Push (head.guid);
            }

            return ACAPI_Element_Delete (wallGuids);
        });
}

 

Requirements

Version: API 23 or later
Header: ACAPinc.h

 

See Also

ACAPI_Element_Delete, API Functions