Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 
Developer forum
GDL coding questions, Python and add-on development using the API Dev Kit.

Refresh all layouts with API



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)

	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);
	if (dbases != NULL)



 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



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:






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.




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


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


Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!