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.

APIDb_GetCurrentDatabaseID problem/bug?

Anonymous
Not applicable
Hello,

I cannot find out which section database I am using on the open notification. I get this problem in both ArchiCAD 9 and ArchiCAD 7.

To replicate this problem I have a simple test. dbUnid and dbIndex are both set from a section that is in the drawing.


APIDatabaseInfo newDB;

memset(&newDB, 0, sizeof(APIDatabaseInfo));
newDB.typeID = APIWindSectionID;
#if ACNINE
newDB.databaseUnId = dbUnid;
#else
newDb.index = dbIndex;
#endif
err = ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &newDB, nil);

// can use the section database ok

memset(&newDB, 0, sizeof(APIDatabaseInfo));
err = ACAPI_Database(APIDb_GetCurrentDatabaseID, &newDB, nil);

// now I cannot get the current database. err == noErr, but...
// newDB.typeID == APIWindSectionID
// newDB.index == 0
// newDB.databaseUnId.id1 == 0
// newDB.databaseUnId.id2 == 0

Is this a bug? I'd like to know what database I just changed to without having to remember myself.

Thanks,
Adam
4 REPLIES 4
Ralph Wessel
Mentor
adambutler wrote:
I'd like to know what database I just changed to without having to remember myself.
Adam,

How about using APIDb_GetCurrentDatabaseID to tell you which one is active? E.g.

	API_DatabaseInfo dbase;
	ACAPI_Database(APIDb_GetCurrentDatabaseID, &dbase, 0);
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
My problem is with APIDb_GetCurrentDatabaseID. It tells me that its a section database but I cannot tell which section because the index/id's are zero.

As a workaround I am now using a global variable to tell which database I last changed to.
Ralph Wessel
Mentor
adambutler wrote:
My problem is with APIDb_GetCurrentDatabaseID. It tells me that its a section database but I cannot tell which section because the index/id's are zero.
Oops - didn't read the question properly

I've checked the instances where I use APIDb_GetCurrentDatabaseID and I get non-zero values. Perhaps the results are dependent on the context in which the call is made?
Ralph Wessel BArch
Software Engineer Speckle Systems
Hoa Tu
Newcomer
Adam,

I use "ACAPI_Automate (APIDo_ChangeWindowID, &windowInfo, NULL);" instead to change to a section/elevation window. It seems working ok.

HTH,

Hoa