Creates a new independent detail, worksheet, layout or master layout database.
GSErrCode ACAPI_Database ( APIDb_NewDatabaseID, API_DatabaseInfo* databaseInfo, const GS::Guid* parent, const GS::Guid* child );
Parameters
- databaseInfo
- [in/out] parameters of the database to be created
- parent
- The parent of the new item.
- child
- If it is nullptr, then the new item will be inserted to the first place on the actual level, otherwise the it will be inserted after the child.
Return Values
NoError
- the function has completed with success.
APIERR_REFUSEDCMD
- the function was refused to execute, because it was called inside an undo scope.
APIERR_NOPLAN
- no floor plan window opened
APIERR_BADPARS
databaseInfo
isnullptr
APIERR_REFUSEDPAR
- the passed
typeID
is notAPIWind_DetailID
,APIWind_WorksheetID
,APIWind_LayoutID
orAPIWind_MasterLayoutID
APIERR_GENERAL
- could not create new database
For other common API errors see the API Errors document.
Remarks
This function is used to create a new database with the given name
and ref
parameters.
No associated window will be opened.
In case of Layout databases you must specify an existing Master Layout in masterLayoutUnId
.
If the database is created successfully, the unique ID of the database returns in the databaseUnId
field.
This function is a non-undoable data structure modifier function. See more details on this topic at Command Overview.
Example
API_DatabaseInfo dbInfo; BNZeroMemory (&dbInfo, sizeof (API_DatabaseInfo)); dbInfo.typeID = APIWind_DetailID; sprintf (dbInfo.name, "Dooku 1"); sprintf (dbInfo.ref, "D01"); if (ACAPI_Database (APIDb_NewDatabaseID, &dbInfo, nullptr) == NoError) { char msgStr[1024]; sprintf (msgStr, "New detail database is created with unId:%d-%d", dbInfo.databaseUnId.id1, dbInfo.databaseUnId.id2); ACAPI_WriteReport (msgStr, true); }
Example2
This example is based on the Navigator_Test test addon.Int32 selected = DGTreeViewGetSelected (dialogID, NavTreeView, DG_TVI_ROOT); Int32 selParent = DGTreeViewGetItem (dialogID, NavTreeView, selected, DG_TVG_PARENT); GS::Guid parent = APIGuid2GSGuid (NavigatorTestGlobals::Instance ().GetNavigatorItem (TruncateTo32Bit (DGTreeViewGetItemUserData (dialogID, NavTreeView, selParent)))); GS::Guid child = APIGuid2GSGuid (NavigatorTestGlobals::Instance ().GetNavigatorItem (TruncateTo32Bit (DGTreeViewGetItemUserData (dialogID, NavTreeView, selected)))); API_DatabaseInfo dbInfo; BNZeroMemory (&dbInfo, sizeof (API_DatabaseInfo)); dbInfo.typeID = APIWind_LayoutID; GS::ucscpy (dbInfo.name, L("This Layout is created through API.\0")); dbInfo.masterLayoutUnId.id2 = 32; ACAPI_Database (APIDb_NewDatabaseID, &dbInfo, &parent, &child);
Requirements
- Version: API 6.1 or later
- Header: APIdefs_Database.h
See Also
API_DatabaseInfo
APIDb_DeleteDatabaseID, APIDb_ModifyDatabaseID, APIDb_GetDatabaseInfoID
APIDb_GetCurrentDatabaseID, APIDb_ChangeCurrentDatabaseID, APIDb_NewWindowID
ACAPI_Database, API Functions