2023-11-11 06:41 AM - last edited on 2024-09-16 02:39 PM by Doreena Deng
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(dbInfo.name, sizeof(dbInfo.name), 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
2023-11-14 04:59 AM
Hi @BerndSchwarzenbacher, Can you help me with this question, please?
2023-11-23 10:23 PM
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 (dbInfo.name, sizeof (dbInfo.name), "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 ());
return;
}
// Clone Worksheet to View Map
API_Guid viewGuid;
err = ACAPI_Navigator (APINavigator_CloneProjectMapItemToViewMapID, &results[0].guid, &folderItem.guid, &viewGuid);
Hope that helps,
Bernd