Archicad C++ API
About Archicad add-on development using the C++ API.

Refresh all layouts with API

MudratDetector
Booster

AC23

Refreshing all layouts is a step in a larger task that will ultimately produce a set of .pdf files of each Architectural layout in a model full of mixed discipline layouts.  I started with code found here.

 

With my edits, I have this:

 

 

 

void RefreshAllLayoutBooks()
{
	API_DatabaseUnId *dbases = NULL;
	API_DatabaseInfo db_orig, dbLayoutBook;
	GSErrCode err;
	Int32 nDbases = 0;
	Int32 intCount = 0;

	err = ACAPI_Database(APIDb_GetCurrentDatabaseID, &db_orig, NULL);
	if(err != NoError)
		return;

	err = ACAPI_Database(APIDb_GetLayoutDatabasesID, &dbases, NULL);
	if (err == NoError)
		{
		nDbases = BMpGetSize(reinterpret_cast<GSPtr>(dbases)) / sizeof(API_DatabaseUnId);
		for (Int32 ii = 0; ii < nDbases; ++ii)
		{
			BNZeroMemory(&dbLayoutBook, sizeof(API_DatabaseInfo));
			dbLayoutBook.typeID = APIWind_LayoutID;
			dbLayoutBook.databaseUnId = dbases[ii];
			intCount = intCount ++;
			GS::UniString strMsg;
			GS::UniString strBlank;
			if (intCount < 10) {
				strBlank = "   ";
			}
			else if (intCount < 100) {
				strBlank = "  ";
			}
			else if (intCount < 1000) {
				strBlank = " ";
			}
			
			err = ACAPI_Database(APIDb_GetDatabaseInfoID, &dbLayoutBook, NULL);
			if (err == NoError) {
				if (dbLayoutBook.ref != GS::UniString("")) {
					GS::UniString strSheetName = dbLayoutBook.ref;
					if (strSheetName.GetSubstring(0, 1) == "A") {
						strMsg = strBlank + GS::UniString::Printf("%d", intCount);
						strMsg = "..." + strMsg + " " + strSheetName;
						ACAPI_WriteReport(strMsg, false);
					}
				}
				else {
					strMsg = strBlank + GS::UniString::Printf("%d", intCount) + GS::UniString(" N.O.T.H.I.N.G");
					strMsg = "+++" + strMsg;
					ACAPI_WriteReport(strMsg, false);
				}
			}
		}
		ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &dbLayoutBook, nullptr);
		ACAPI_Database(APIDb_RebuildCurrentDatabaseID);
	}
	if (dbases != NULL)
		BMpFree(reinterpret_cast<GSPtr>(dbases));
}

 

 

 The output of the above code is:

 

 

...   2 A002
...   5 A001
+++   7 N.O.T.H.I.N.G
+++   8 N.O.T.H.I.N.G
... 131 A123
... 132 A200
... 133 A311
... 134 A110a
... 135 A101
etc.

 

 

This confirms for me that I am on the right track for capturing only the Architectural sheets in the model.  And capturing/not processing a sheet that has no discipline assigned to it.  [Not sure what that is all about yet].  The number between the "..." and the sheet number is only a sequential number that is incremented as I examine each layout for inclusion in the set of Architectural sheets.

 

I am having trouble understanding why the update of the layouts with:

 

 

ACAPI_Database(APIDb_RebuildCurrentDatabaseID)

 

 

does not occur.  I am verifying the update by adding a couple of random walls and verifying success of this process with a manual update.

 

my problem:

I believe I have not captured the proper database ID and/or have not set it as current.  Maybe the choice of functions used is not correct.  I am not sure.  Any direction provided would be helpful.

 

Thanks,

chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
1 REPLY 1

ramisthand76
Participant

Update Page Layout with Metadata API (using REST API). Hi everyone! I need to add new account custom fields to the account page layout.

mobdro

myfiosgateway.one

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!