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

Bundling .gsm files

kency
Booster

Hello Team,

 

We would like to bundle a set of gsm files with the Add-On. I got to know from my previous query in the community that it is possible. The documentation mentions about a Stair Marker Add-On which I could not find in the Examples folder.  However, I am not yet clear on how to add a folder while building the bundle. (I am new to C++ as well). Any guidance on how to add a folder to the bundle would be really helpful.

 

kency_0-1700588992293.png

 

I have been able to successfully load a folder into the library using the below snippet:

 

 

 

GSErrCode CreateLibrary (void)
{
    IO::Location newLib("~/Work/library/types/gsm");
    GSErrCode err;
    err = ACAPI_Environment (APIEnv_AddLibrariesID, &newLib);
    if (err == NoError){
       std::cout << "New library has been loaded" << std::endl;
    }
    return err;
}

 

 

 

 

3 REPLIES 3

Hi Kency,

 

This is possible, but there are quite a lot of things to take care of. It took me a while to get this working.

Here are a few thoughts/tips:

 

  1. You can use ACAPI_Goodies with APIAny_GetBuiltInLibpartUnIdID (<= AC26) or ACAPI_LibraryPart_GetBuiltInLibpartUnId (AC27) to get the the library part unique id from its resource id. "132" is the resource id in your screenshot.
  2. As you have found, ACAPI_Register_BuiltInLibrary (<=AC26) or ACAPI_AddOnIntegration_RegisterBuiltInLibrary (AC27) is important. I think this also requires your CheckEnvironment function to return APIAddon_Preload.
  3. Make sure that your Resource build step includes the file! You might have to adapt the CompileResources.py script in case you are using the CMake templates.

 

Side Note: The stair-maker Add-On is not an available example project. It was shipped a few versions ago with Archicad I think.

Hope that helps,
Bernd

 

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: bschwb.com
kency
Booster

1. The 132 in the screenshot is from the documentation. How do we get the id before loading the library part? 

2. Ok, will check out the APIAddon_Preload

3. Yes, I am using the CMake templates. I made changes in the CMakeList file to include .lcf file as shown in the screenshot

kency_0-1701086769936.png

 

1. The resource id is a number you choose yourself and put into the resource file. So it could be 132 like in the example or any other positive number below 32767 (or something like this, can't find the source for this anymore. I think it was related to maximum repr. of 2^15 somehow which would be max value of short if it's 2 bytes). You can get the library id from your chosen resource id as described above.

 

3. The way I do it is by including the single .gsm files, not a complete .lcf container. I'm not sure if there's even a way to achieve it with a whole library container. Also as said above, you'll have to make sure that the files are included in the resource compilers output. I'd suggest studying the CompileResources.py script and checking it's output.

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

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!