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
isnullptr
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 ChangeCurrentDatabaseToDatabaseOfSectionElement (const API_Guid& guid) { API_Element element = {}; element.header.guid = guid; GSErrCode err = ACAPI_Element_Get (&element); if (err != NoError) return err; if (element.header.type != API_CutPlaneID) return Error; API_DatabaseInfo databasePars = {}; databasePars.typeID = APIWind_SectionID; databasePars.databaseUnId = element.cutPlane.segment.databaseID; err = ACAPI_Database (APIDb_ChangeCurrentDatabaseID, &databasePars); return err; }
Requirements
- Version: API 4.1 or later
- Header: APIdefs_Database.h
See Also
API_DatabaseInfo,
APIDo_ChangeWindowID,
ACAPI_Database, API Functions