We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Choosing the door from library through Add-On code

kency
Enthusiast

Hello team,

 

  1. Wanted to know how we can specify the kind of door that we want through code?
  2. Is it possible to load a set of custom doors/windows through add-on code or should we do it as a different step.

kency_0-1699444528080.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Akos Somorjai
Graphisoft
Graphisoft

Hi,

 

1. If you know the name of the door, then you can use ACAPI_LibPart_Search() to find the index of that library part, then get that library part's parameters as well with ACAPI_LibPart_GetParams().

Put the index into the openingBase.libInd member of API_WindowType, and add the library part parameters to addPars in API_ElementMemo, then call ACAPI_Element_Create().

 

2. There are several ways to do that:

  • have the user load the library separately 🙂
  • add the library to the list of loaded libraries with ACAPI_LibraryManagement_AddLibraries()

 

Best, Akos

View solution in original post

7 REPLIES 7
Solution
Akos Somorjai
Graphisoft
Graphisoft

Hi,

 

1. If you know the name of the door, then you can use ACAPI_LibPart_Search() to find the index of that library part, then get that library part's parameters as well with ACAPI_LibPart_GetParams().

Put the index into the openingBase.libInd member of API_WindowType, and add the library part parameters to addPars in API_ElementMemo, then call ACAPI_Element_Create().

 

2. There are several ways to do that:

  • have the user load the library separately 🙂
  • add the library to the list of loaded libraries with ACAPI_LibraryManagement_AddLibraries()

 

Best, Akos

kency
Enthusiast

Thank you @Akos Somorjai . Will try this out.

Akos Somorjai
Graphisoft
Graphisoft

There is a Do_CreateWindow() sample code in Element_Test; this may serve as a starting point.

 

Best, Akos

@Akos Somorjai For point 2. Is it possible to add the library file(.lcf) as part of the .bundle or .apx and provide code to load from the file included in the add-on bundle. I was able to load the library given a location from where to pick it up. Something mentioned in this documentation of ArchiCAD 25. Am I looking for something that is not possible to be done.

 

kency_0-1700651625897.png

 

Hi kency,

 

No, you may only add individual .gsm files as resources. You may ship an .lcf file with the add-on, but then you'll have to add it from code with ACAPI_Environment (APIEnv_AddLibrariesID, ...).

 

Best, Akos

kency
Enthusiast

Ok, maybe I am stuck at something really simple. I have added an .lcf file in the Resources folder of the Add-On. (updated cmake to include .lcf files).

Now,

How should I ship/bundle it? Is there anything additional that needs to be done for that.

Also, how can I refer to that file in the code? Right now I have been able to load from an absolute path as shown in the snippet below.

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

 Thank you!

Hi,

 

I would ship it together with the add-on, but as a separate file. Ask the user to place the two together into a folder, and then from your code you can get the add-on's location in the file system with ACAPI_GetOwnLocation() and load the .lcf from there.

 

Best, Akos