Create and change database to newly created db
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2015-11-11
06:30 PM
- last edited on
2023-07-13
02:48 PM
by
Doreena Deng
2015-11-11
06:30 PM
When I try to switch current database to newly created worksheet, I get APIERR_BADDATABASE (The command cannot be executed on the current database). The worksheet is sucessfully created but changing database fails. What am I doing wrong here??
GSErrCode err; API_DatabaseInfo dbInfo; BNZeroMemory (&dbInfo, sizeof (API_DatabaseInfo)); dbInfo.typeID = APIWind_WorksheetID; CHANSI2Unicode ("Det 1", (GS::Int32)strlen("Det 1"), dbInfo.name, API_UniLongNameLen); CHANSI2Unicode ("D10", (GS::Int32)strlen("D10"), dbInfo.ref, API_UniLongNameLen); if (ACAPI_Database (APIDb_NewDatabaseID, &dbInfo, NULL) == NoError) { err = ACAPI_Database (APIDb_ChangeCurrentDatabaseID, &dbInfo, NULL); }
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Labels:
- Labels:
-
Add-On (C++)
3 REPLIES 3

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2015-11-12 12:19 PM
2015-11-12
12:19 PM
You need to open the window this database after creation, before the database using.
( I dont check it in last APIs, may be it changed ).
ACAPI_Automate( APIDo_ChangeWindowID, &m_db, NULL );
( I dont check it in last APIs, may be it changed ).
ACAPI_Automate( APIDo_ChangeWindowID, &m_db, NULL );
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2015-11-12 01:35 PM
2015-11-12
01:35 PM
Works! Thanks Oleg.
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2016-01-19 10:44 AM
2016-01-19
10:44 AM
vuego wrote:This can be simplified to:
CHANSI2Unicode ("Det 1", (GS::Int32)strlen("Det 1"), dbInfo.name, API_UniLongNameLen); CHANSI2Unicode ("D10", (GS::Int32)strlen("D10"), dbInfo.ref, API_UniLongNameLen);
GS::ucscpy (dbInfo.name, L("Det 1")); GS::ucscpy (dbInfo.ref, L("D10"));Best, Ákos