License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

Create and change database to newly created db

Miha Nahtigal
Advocate
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.
3 REPLIES 3
Oleg
Expert
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 );
Miha Nahtigal
Advocate
Works! Thanks Oleg.
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
Akos Somorjai
Graphisoft
Graphisoft
vuego wrote:

	CHANSI2Unicode ("Det 1", (GS::Int32)strlen("Det 1"), dbInfo.name, API_UniLongNameLen);
	CHANSI2Unicode ("D10", (GS::Int32)strlen("D10"), dbInfo.ref, API_UniLongNameLen);

This can be simplified to:

	GS::ucscpy (dbInfo.name, L("Det 1"));
	GS::ucscpy (dbInfo.ref, L("D10"));
Best, Ákos