BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

Changing the Library folder in ARCHICAD12

Anonymous
Not applicable
Hi,

I want to change my project Libraries Folder in ArchiCAD 12.
I am using following function.

Void setupLibrariesForAC12()
{
API_LibrariesInfo libInfo;

memset(&libInfo, 0, sizeof(API_LibrariesInfo));
libInfo.nLib = 2;
libInfo.locations = (IO::Location**) BMAllocateHandle (libInfo.nLib * sizeof(IO::Location, ALLOCATE_CLEAR, 0);
libInfo.useSatellite = false;

new (*libInfo.locations) IO::Location (“C:\\Archicad12\\Archicad Library”);
new (*libInfo.locations + 1) IO::Location (“C:\\Archicad Development Library”);

ACAPI_Environment(APIEnv_SetLibrariesID, &libInfo, NULL);
(*libInfo.locations).~Location();
(*libInfo.locations + 1).~Location();

BMKillHandle(reinterpret_cast<GSHandle *> (&libInfo.locations));
}

But I am getting following errors
err LNK2001:unresolved external symbol “public: virtual class GS::ClassInfo * __thiscall GS::Object::GetClassInfoA(void)const “(?getClassInfoA@object@GS@@UBEPAVClassInfo@2@XZ)
fatal error LNK1120: 1 unresolved externals.

Please help me to solve these errors.
23 REPLIES 23
Anonymous
Not applicable
I'm sorry, may be it's wrong topic.. Really I don't need to change Library folder. I need additional properties of project that can get via AutoText.
But I have the same linker error.
Anonymous
Not applicable
I have drawings in ArchiCAD 9.0 and I am opening those drawings in ArchiCAD 12.0.
I have two separate libraries for ArchiCAD 9.0 and 12.0. so, I am changing the library path in the drawing opening process by using apx.

I wrote the code as fallow

OSErr DoOpen()
{
	HWND hwnd = FindWindow(NULL, "Library Loading Report");
	if(hwnd)
		SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
	SetupLibrariesForAC12(); // Changing the Library Path
	hwnd = FindWindow(NULL, "Library Loading Report");
	if(hwnd)
		SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);

	if(SetLayerCombo("API-AllUnlockedAndShown")) // Set the layer combo.
		return noErr;
	else
		MessageBox(ACAPI_GetMainWindow(),"Problem to set layer Combo", " Tamawood Alert", MB_OK);
}

void SetupLibrariesForAC12()
{
	API_LibrariesInfo libInfo;
	OSErr err;
	char libPath[MAX_PATH];
	bool defaultFound = false;

	memset(&libInfo, 0, sizeof(API_LibrariesInfo));
	err = ACAPI_Environment(APIEnv_GetLibrariesID, &libInfo, NULL);
	if(err != noErr)
	{
		MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK);
		return;
	}

	for(int ii = 0; ii < libInfo.nLib; ++ii)
	{
		strcpy(libPath, GetCPathFromLocation(&(*libInfo.locations)[ii]));
		if(stricmp(libPath, "C:\\Program Files\\Graphisoft\\ArchiCAD 12\\Tamawood Library 12") == 0)
			defaultFound = true;

		(*libInfo.locations)[ii].~Location();
	}

	if(libInfo.location_Satellite)
		delete libInfo.location_Satellite;
	BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations));

 
	if(!defaultFound)
	{
		memset(&libInfo, 0, sizeof(API_LibrariesInfo));
		libInfo.nLib = 1;
		
		libInfo.locations = (IO::Location**) BMAllocateHandle (libInfo.nLib * sizeof (IO::Location), ALLOCATE_CLEAR, 0);
		libInfo.useSatellite = false;
		(*libInfo.locations)[0] = IO::Location("C:\\Program Files\\Graphisoft\\ArchiCAD 12\\Tamawood Library 12");

		err = ACAPI_Environment(APIEnv_SetLibrariesID, &libInfo, NULL);
		if(err != noErr)
			MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK);

		BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations));
	}
}
BOOL SetLayerCombo(char * pLayerCombo)
{
	API_Attr_Head attribHead;
	OSErr err;
	short currentCombo;

	memset(&attribHead, 0, sizeof(API_Attr_Head));
	strcpy(attribHead.name, pLayerCombo);
	attribHead.typeID = API_LayerCombID;
	attribHead.guid = APINULLGuid;
	err = ACAPI_Attribute_Search(&attribHead);
	if(err != noErr)
	{
		MessageBox(ACAPI_GetMainWindow(), "ERROR: Unable to find layer combo", "Tamawood Alert", MB_OK);
		return false;
	}

	currentCombo = 0;
	err = ACAPI_Environment(APIEnv_GetCurrLayerCombID, &currentCombo, NULL, NULL);
	if(err != noErr || attribHead.index != currentCombo)
	{
		err = ACAPI_Environment(APIEnv_ChangeCurrLayerCombID, &attribHead.index, NULL, NULL);
		if(err != noErr)
		{
			MessageBox(ACAPI_GetMainWindow(), "ERROR: Unable to find layer combo", "Tamawood Alert", MB_OK);
			return false;
		}
	}
	return true;
}
It was successfully changing the Library path but, while changing the layer combo at the following line
err = ACAPI_Environment(APIEnv_ChangeCurrLayerCombID, &attribHead.index, NULL, NULL); system was crashing.

I checked the values of variables in debug mode just before above line were.
attribHead.index = 74;
currentCombo = 76;

if remark the following lines in doopen()

	SetupLibrariesForAC12(); // Changing the Library Path
	hwnd = FindWindow(NULL, "Library Loading Report");
	if(hwnd)
		SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
It works fine (if I am not changing the Library path).

Can any one give me some suggestions please?
Ralph Wessel
Mentor
Ranga wrote:
I have two separate libraries for ArchiCAD 9.0 and 12.0. so, I am changing the library path in the drawing opening process by using apx.
if remark the following lines in doopen()

	SetupLibrariesForAC12(); // Changing the Library Path
	hwnd = FindWindow(NULL, "Library Loading Report");
	if(hwnd)
		SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
It works fine (if I am not changing the Library path).
Some thoughts:
  • 1) If you call APIEnv_SetLibrariesID, the current list of loaded libraries will be entirely replaced by the list you specify. Your code will always reduce the list to a single item (the ArchiCAD 12 library).
    2) Ákos has confirmed that you should also use placement new and delete to construct the list of library locations. This change might solve your problem
Ralph Wessel BArch
Anonymous
Not applicable
Hi, we have a function in ArchiCAD 12. Which will change the library. And work ok.
Which is

void SetupLibrariesForAC12() 
{ 
   API_LibrariesInfo libInfo; 
   OSErr err; 
   char libPath[MAX_PATH]; 
   bool defaultFound = false; 

   memset(&libInfo, 0, sizeof(API_LibrariesInfo)); 
   err = ACAPI_Environment(APIEnv_GetLibrariesID, &libInfo, NULL); 
   if(err != noErr) 
   { 
      MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK); 
      return; 
   } 

   for(int ii = 0; ii < libInfo.nLib; ++ii) 
   { 
      strcpy(libPath, GetCPathFromLocation(&(*libInfo.locations)[ii])); 
      if(stricmp(libPath, "C:\\Program Files\\Graphisoft\\ArchiCAD 12\\Tamawood Library 12") == 0) 
         defaultFound = true; 

      (*libInfo.locations)[ii].~Location(); 
   } 

   if(libInfo.location_Satellite) 
      delete libInfo.location_Satellite; 
   BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations)); 

  
   if(!defaultFound) 
   { 
      memset(&libInfo, 0, sizeof(API_LibrariesInfo)); 
      libInfo.nLib = 1; 
       
      libInfo.locations = (IO::Location**) BMAllocateHandle (libInfo.nLib * sizeof (IO::Location), ALLOCATE_CLEAR, 0); 
      libInfo.useSatellite = false; 
      (*libInfo.locations)[0] = IO::Location("C:\\Program Files\\Graphisoft\\ArchiCAD 12\\Tamawood Library 12"); 

      err = ACAPI_Environment(APIEnv_SetLibrariesID, &libInfo, NULL); 
      if(err != noErr) 
         MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK); 

      BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations)); 
   } 
} 
Now I changed this function for ArchiCAD 13 and is not working.
New function is

void SetupLibrariesForAC13() 
{ 
   API_LibrariesInfo libInfo; 
   OSErr err; 
   char libPath[MAX_PATH]; 
   bool defaultFound = false; 

   memset(&libInfo, 0, sizeof(API_LibrariesInfo)); 
   err = ACAPI_Environment(APIEnv_GetLibrariesID, &libInfo, NULL); 
   if(err != noErr) 
   { 
      MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK); 
      return; 
   } 

   for(int ii = 0; ii < libInfo.nLib; ++ii) 
   { 
      strcpy(libPath, GetCPathFromLocation(&(*libInfo.locations)[ii])); 
      if(stricmp(libPath, "C:\\Program Files\\Graphisoft\\ArchiCAD 13\\Tamawood Library 13") == 0) 
         defaultFound = true; 

      (*libInfo.locations)[ii].~Location(); 
   } 

   if(libInfo.location_Satellite) 
      delete libInfo.location_Satellite; 
   BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations)); 

  
   if(!defaultFound) 
   { 
      memset(&libInfo, 0, sizeof(API_LibrariesInfo)); 
      libInfo.nLib = 1; 
       
      libInfo.locations = (IO::Location**) BMAllocateHandle (libInfo.nLib * sizeof (IO::Location), ALLOCATE_CLEAR, 0); 
      libInfo.useSatellite = false; 
      (*libInfo.locations)[0] = IO::Location("C:\\Program Files\\Graphisoft\\ArchiCAD 13\\Tamawood Library 13"); 

      err = ACAPI_Environment(APIEnv_SetLibrariesID, &libInfo, NULL); 
      if(err != noErr) 
         MessageBox(ACAPI_GetMainWindow(), "ERROR:\n", "Tamawood Alert", MB_OK); 

      BMKillHandle (reinterpret_cast<GSHandle *> (&libInfo.locations)); 
   } 
} 
And I noticed Location.hpp in InputOutput module is modified. Please any one give me any suggestions to change library.
Learn and get certified!