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.

APIDo_​ReloadLibrariesID function work around

Anonymous
Not applicable
Hello all,

First off, I want to say thank you to all the developers for answering questions here because they have helped me quite a bit without me having to start a thread. Also, a thank you the users who ask great questions and create a lot of content for this board. Although it took a little effort in the beginning to get started, I'm quite happy with the progress I've made on a project I've been working on. Most of the time, just when I think I'm stumped, I get the right clues from this board, or I read enough documentation to get me through.

But this time, I think I need ask for advice.

I've created an add on that is intended to work with Archicad v19 and v22. I use the`APIDo_​ReloadLibrariesID` function that is available for me in DevKit v22 - but I can't use it in DevKit v19 because it isn't available. Is there a way to use other available API functions in DevKit v19 to achieve the same process?

I've tried to use this order of operations or similar:

1. APIEnv_​GetLibrariesID

2. APIEnv_​ResetLibrariesID

3. APIDo_​LoadLibrariesID or APIEnv_​SetLibrariesID or APIEnv_​AddLibrariesID

I've tried various implementations but I can't seem to recreate the same result - In general, it seems these functions don't detect changes in the library folder contents and updates with those changes like it would when I use the`APIDo_​ReloadLibrariesID` function in DevKit 22.

Another way of phrasing my question is "Can I write code to achieve the same result when I launch Archicad v19, open the Library Manager, and select `Reload Libraries and Apply all the Changes`?"
4 REPLIES 4
Ralph Wessel
Mentor
APIDo_LoadLibrariesID should do a full reload of the library. What does it seem to do (or not do) when you call it?
Ralph Wessel BArch
Anonymous
Not applicable
Ralph,

Thanks for your prompt response.

Wouldn't you know it? I think I solved my problem - and just as I was about to post the solution, I saw your response... I was expecting an email notification for a reply but perhaps I didn't set some option I was supposed to.

Anyways, the add on is used to create and place new library parts on the work space. Each newly created library part writes a script that reads a .gspc file in the same folder as the .gsm file for that library part.

Later on during use, the user can select the library part on the work space, and the add on can reload the part to make changes to it. When the user wants to 'update' the library part with changes, the add on will overwrite the .gspc file for that library part. This is where I need to reload the libraries to see the changes. Simply overwriting the .gspc doesn't show the change on the work space - which makes sense.

In DevKit v22, I can use `APIDo_​ReloadLibrariesID` to show the data in the .gspc has changed - but when I try to use `APIDo_​LoadLibrariesID` with DevKit v19 it does not show these changes.

However, if I do the following I will see changes:

1. APIEnv_GetLibrariesID

2. APIEnv_ResetLibrariesID

3. APIDo_LoadLibrariesID

4. ACAPI_LibPart_Register

The changes manifest after calling `ACAPI_LibPart_Register`. However, I cannot simply call `ACAPI_LibPart_Register` by itself - it seems I must reset and reload the libraries prior to the call and then it works.
Ralph Wessel
Mentor
If you're overwriting an existing library part, I wonder if APIEnv_OverwriteLibPartID might help you? That would signal to ARCHICAD that the particular object you're writing should replace one that is currently loaded and presumably update anything based on that object in the project.
Ralph Wessel BArch
Anonymous
Not applicable
I did a few experiments. In each one, when I used `APIEnv_OverwriteLibPartID`, I did so following the example in the documentation (ie: call `APIEnv_OverwriteLibPartID` to set an overwrite flag, call `ACAPI_LibPart_Create` to save the updated Library Part, then call `APIEnv_OverwriteLibPartID` to reset the overwrite flag).

The following was attempted without success:

Method 1:
1. APIEnv_OverwriteLibPartID

Method 2:
1. APIEnv_OverwriteLibPartID
2. ACAPI_LibPart_Register

Method 3:
1. APIEnv_OverwriteLibPartID
2. APIEnv_GetLibrariesID
3. APIEnv_ResetLibrariesID
4. APIDo_LoadLibrariesID

Method 4 (Like Method 3 but call `APIEnv_OverwriteLibPartID` last):
1. APIEnv_GetLibrariesID
2. APIEnv_ResetLibrariesID
3. APIDo_LoadLibrariesID
4. APIEnv_OverwriteLibPartID

I might be missing a few other variations - but if I had to guess, I would say that calling `APIEnv_OverwriteLibPartID` doesn't detect changes because the Library Part parameters and its script content don't change - just the .gspc data.

It might help to mention when I overwrite the .gspc I use the same name as it had before. It seems calling `ACAPI_LibPart_Register' forces the reread of the .gspc file - yet I must reset and reload the libraries before it will do so.
Learn and get certified!