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

How to get the navigator main tree name?

ReignBough
Enthusiast
[See attached file.]

I can get this name by calling ACAPI_Environment(APIEnv_GetProjectNotesID) and use the value of projectName. When this is empty, I call ACAPI_Environment(APIEnv_ProjectID) and check the untitled flag: if true, I set the tree name to 'Untitled'; if false, I use the project file name (proj_info.location->GetLastLocalName()). This is true for PLN file.

But when I started from an existing PLA file and follows the steps above the add-on fails. This is because the untitled flag is true and the tree name is set to the PLA file name. Also since it is flagged as untitled, the location value is empty.

Is there any other way on getting this name without calling/getting it from the navigator?

navigator_tree.jpg
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
1 REPLY 1
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
ReignBough wrote:
Is there any other way on getting this name without calling/getting it from the navigator?


Why don't you want to get it from the navigator?

I would use this code to get that:
API_NavigatorSet set; 
BNZeroMemory (&set, sizeof (API_NavigatorSet)); 
set.mapId = API_ProjectMap; 
GSErrCode err = ACAPI_Environment (APIEnv_GetNavigatorSetID, &set, NULL); 
if (err == NoError) { 
	char buffer[256]; 
	sprintf (buffer, "Project name: %s", set.name); 
	ACAPI_WriteReport (buffer, true); 
 
	// to check root item's name 
	API_NavigatorItem navItem; 
	BNZeroMemory (&navItem, sizeof (API_NavigatorItem)); 
	navItem.mapId = API_ProjectMap; 
	err = ACAPI_Environment (APIEnv_GetNavigatorItemID, &set.rootGuid, &navItem); 
	if (err == NoError) { 
		sprintf (buffer, "Root navigator item name: %s", navItem.name); 
		ACAPI_WriteReport (buffer, true); 
	} 
}


Regards,
Tibor