APIDb_​ChangeCurrentDatabaseID

Changes the current (active) database.

    GSErrCode ACAPI_Database (
        APIDb_ChangeCurrentDatabaseID,
        API_DatabaseInfo*     databaseInfo
    );

 

Parameters

databaseInfo
[in] parameters of the database to be created (type, reference index)

 

Return Values

NoError
The function has completed with success.
APIERR_BADPARS
databasePars is nullptr
APIERR_NOPLAN
no open project
APIERR_BADDATABASE
the requested database does not exist

For other common API errors see the API Errors document.

 

Remarks

This function is used to change the current database in the background. All the subsequent API calls to any database dependent function will work on the specified database.

This function can be very expensive in case of low memory condition. The server application tries to keep as many database object in the memory as possibly, however it can happen, that some of them must be swapped out. Switching to an other database means, that the server application loads it into the memory, which may cause others to be unloaded. It can be a relatively long time.

Refer to the APIDo_ChangeWindowID function in the case you want to change not only the database in the background, but the current front window also.

 

Example


GSErrCode ChangeCurrentDatabase (const API_Guid& guid)
{
    API_Element         element;
    API_DatabaseInfo    databasePars;
    GSErrCode           err;

    BNZeroMemory (&element, sizeof (API_Element));
    element.header.guid = guid;

    err = ACAPI_Element_Get (&element);

    if (err == NoError) {
        BNZeroMemory (&databasePars, sizeof (API_DatabaseInfo));
        databasePars.typeID = APIWind_SectionID;
        databasePars.databaseUnId = element.cutPlane.databaseID;

        err = ACAPI_Database (APIDb_ChangeCurrentDatabaseID, &databasePars, nullptr);
    }

    return err;
}

 

Requirements

Version: API 4.1 or later
Header: APIdefs_Database.h

 

See Also

API_DatabaseInfo,
APIDo_ChangeWindowID,
ACAPI_Database, API Functions