2009-02-04
07:53 AM
- last edited on
2024-09-09
10:54 AM
by
Doreena Deng
2009-04-14 02:49 PM
2009-07-24 07:56 AM
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, ¤tCombo, 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 lineSetupLibrariesForAC12(); // 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).
2009-07-24 02:31 PM
Ranga wrote:Some thoughts:
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).
2010-09-24 05:11 AM
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.
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.