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

How to add a worksheet and a view into a folder in ArchiCAD API?


Hi guys, 

Can you help me with this?

I created a worksheet like this:


// Create WorkSheet
API_DatabaseInfo dbInfo = {};
dbInfo.typeID = APIWind_WorksheetID;
GS::snuprintf(, sizeof(, viewName.ToUStr().Get());
//GS::snuprintf(dbInfo.ref, sizeof(dbInfo.ref), "W01");
ACAPI_Database(APIDb_NewDatabaseID, &dbInfo);

And also tried to create a view and a folder like this:

//Create Folder
API_NavigatorItem folderItem;
BNZeroMemory(&folderItem, sizeof(API_NavigatorItem));

folderItem.itemType = API_FolderNavItem;
folderItem.mapId = API_PublicViewMap;

GS::ucscpy(folderItem.uName, viewName.ToUStr());

ACAPI_Navigator(APINavigator_NewNavigatorViewID, &folderItem, NULL, NULL);

GS::Guid parentAndChild[2];
parentAndChild[0] = APIGuid2GSGuid(folderItem.guid);// Folder guid
parentAndChild[1] = APIGuid2GSGuid(APINULLGuid);

API_NavigatorItem saveItem;
BNZeroMemory(&saveItem, sizeof(API_NavigatorItem));

saveItem.itemType = API_StoryNavItem;
saveItem.mapId = API_PublicViewMap;
saveItem.floorNum = story.Id;

GS::ucscpy(saveItem.uName, viewName.ToUStr());

saveItem.customName = true;
API_NavigatorView saveView;
BNZeroMemory(&saveView, sizeof(API_NavigatorView));
ACAPI_Navigator(APINavigator_NewNavigatorViewID, &saveItem, &saveView, parentAndChild);//saveItem


Now I want to create a view from the worksheet above, then I want to add the view from the worksheet and a newly created view to a newly created folder as above.

Can you give me advice? thank you very much


Hi @BerndSchwarzenbacher, Can you help me with this question, please?

Hi Thanh,

Your first two steps of creating the worksheet and the view folder are correct.
I think you provided wrong information for the APINavigator_NewNavigatorViewID function. Namely the parentAndChild guid is provided incorrectly and also saveItem probably needs more information (specifically the guid of the navigator item). In general it's important to distinguish between the Database and a corresponding Navigator Item.

Anyway I found it's easiest with the APINavigator_CloneProjectMapItemToViewMapID function. To get the guid of the navigator item corresponding to the worksheet database, we use the search function. Note that the following example only works if the "test" worksheet is not yet created.


// Create WorkSheet
API_DatabaseInfo dbInfo = {};
dbInfo.typeID = APIWind_WorksheetID;
GS::snuprintf (, sizeof (, "test");
GSErrCode err = ACAPI_Database (APIDb_NewDatabaseID, &dbInfo, nullptr, nullptr);

// Create Folder
API_NavigatorItem folderItem{};
folderItem.itemType = API_FolderNavItem;
folderItem.mapId = API_PublicViewMap;
GS::ucscpy (folderItem.uName, L"ViewFolderTestFolder");
err = ACAPI_Navigator (APINavigator_NewNavigatorViewID, &folderItem);

// Find Worksheet Navigator Item
GS::Array<API_NavigatorItem> results;
API_NavigatorItem search{};
search.mapId = API_ProjectMap;
search.itemType = API_WorksheetDrawingNavItem;
search.db = dbInfo;

err = ACAPI_Navigator (APINavigator_SearchNavigatorItemID, &search, nullptr, &results);
if (results.GetSize () != 1) {
	ACAPI_WriteReport ("Size: %d", true, results.GetSize ());

// Clone Worksheet to View Map
API_Guid viewGuid;
err = ACAPI_Navigator (APINavigator_CloneProjectMapItemToViewMapID, &results[0].guid, &folderItem.guid, &viewGuid);

Hope that helps,

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website:

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!