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.
SOLVED!

ACAPI_LibPart_RegisterAll only registers the last libPart in the array

roni
Booster

Hi All,
I was trying to register a list of libParts, later to create Surfaces using them.

 

 

 

 

GS::Array<API_LibPart> libParts;    
for (const auto& location : textureFileNewLocationList) {
        
        IO::Location nonConstLocation = location;
        std::cout<<UNISTR_TO_LIBXLSTR(nonConstLocation.ToDisplayText()) << std::endl;
        
        API_LibPart libPart;
        BNZeroMemory (&libPart, sizeof (API_LibPart));
        
        libPart.typeID = APILib_PictID;
        libPart.location = &nonConstLocation;
        
        libParts.Push (libPart);
    }
err = ACAPI_LibPart_RegisterAll (&libParts);

 

 

 

 

In the above code textureFileNewLocationList is a array of file locations of images I plan to use. After executing the code, it registers only the last element of the array. In my case I have 55 libParts to register, only 55th have successfully registered.
If I go and check Files → Library and Objects → Library Manager, the box will show one surface got loaded, other 54 were missing.

A manual Reload in the ArchiCAD will load all the libParts

Using ArchiCAD 25

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Used below code

for (const IO::Location& location : textureFileNewLocationList) {
        IO::Location* nonConstLocation = new IO::Location(location.ToDisplayText());

        API_LibPart libPart = {};
        BNZeroMemory (&libPart, sizeof (API_LibPart));
        libPart.typeID = APILib_PictID;
        libPart.location = nonConstLocation;

        libParts.Push(libPart);
    }

View solution in original post

2 REPLIES 2
roni
Booster

Update
I used below code, which loads the Lib Parts of mine but deletes all other default libraries provided by ArchiCAD

    API_LibraryInfo libInfo;
    IO::Location outputLoc (GetSpecialFolderLocation (API_ApplicationFolderID), IO::Name ("/Users/roni/Library/Application Support/GRAPHISOFT/AutoSave-25-2"));
    libInfo.location = outputLoc;
    GS::Array<API_LibraryInfo>    lip = {libInfo};
    err = ACAPI_Automate (APIDo_LoadLibrariesID, &lip);
    if (err != NoError) {
        ACAPI_WriteReport ("Error in APIDo_LoadLibrariesID", true);
    }

 

Solution

Used below code

for (const IO::Location& location : textureFileNewLocationList) {
        IO::Location* nonConstLocation = new IO::Location(location.ToDisplayText());

        API_LibPart libPart = {};
        BNZeroMemory (&libPart, sizeof (API_LibPart));
        libPart.typeID = APILib_PictID;
        libPart.location = nonConstLocation;

        libParts.Push(libPart);
    }
Learn and get certified!

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!