APIDo_​SaveAsModuleFileID

Saves the selected elements into a module file.

    GSErrCode ACAPI_Automate (
        APIDo_SaveAsModuleFileID,
        IO::Location*       location,
        API_Elem_Head**     elemHead
    );

 

Parameters

location
[in] Specifies the module file to be saved
elemHead
[in] Elements to save into the module. Optional parameter, can be nullptr – in this case the current selection is saved

 

Return Values

NoError
The function has completed with success.
APIERR_BADDATABASE
The current database must be floor plan, section/elevation or detail type
APIERR_BADPARS
The fileSpec parameter is nullptr or the file specified by fileSpec cannot be registered
APIERR_BADINDEX
There were no valid elements passed in the elemHead parameter
APIERR_GENERAL
Cannot create or write the module file
APIERR_MEMFULL
Low memory condition

 

Remarks

This function is used to create a module file from a selection of elements. The elements that the module should contain can be passed in the elemHead handle. If this parameter is nullptr, the function uses the current selection, similarly to the ‘Save Selection as Module’ menu command. The module file will not be created if there are no valid elements to save.
Do not forget to release the elemHead handle when not needed any more.

This function is a non-undoable data structure modifier function. See more details on this topic at Command Overview.

 

Example


/* save all elements in the current zoom as module file */

IO::Location            location ("C:\\temp\\CurrentView.mod");
API_SelectionInfo       selectionInfo;
GSErrCode               err = NoError;

if (location.GetStatus () == NoError) {
    BNZeroMemory (&selectionInfo, sizeof (API_SelectionInfo));
    selectionInfo.typeID = API_MarqueeHorBox;
    ACAPI_Database (APIDb_GetZoomID, &selectionInfo.marquee.box, nullptr);
    err = ACAPI_Selection_SetMarquee (&selectionInfo);  /* set the marquee rect to the current zoom */
}

if (err == NoError) {
    err = ACAPI_Automate (APIDo_SaveAsModuleFileID, &location, nullptr);
    BNZeroMemory (&selectionInfo, sizeof (API_SelectionInfo));
    ACAPI_Selection_SetMarquee (&selectionInfo);        /* remove the marquee */
}

 

Requirements

Version: API 4.1 or later
Header: APIdefs_Automate.h

 

See Also

API_Elem_Head
ACAPI_Automate
API Functions