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.

Create library (LibPart) based on an existing one

ReignBough
Enthusiast
I am trying to create a library from an existing one. What I did was just get all the information from the "source" library then copy (and modify) them. I am able to do this but limited to some section. Based on the documentation, ACAPI_LibPart_GetSection() will return APIERR_BADPARS for pictures, macros, etc.

I also followed the example given at the documentation of ACAPI_LibPart_GetSectionList(), modify it so that I will create a "destination" library.

When I called ACAPI_LibPart_GetSection(), I got APIERR_BADPARS and APIERR_NOLIBSECT on some of the sections. This means that the list that I got form ACAPI_LibPart_GetSectionList() have a "non-existing" section; or (as I interpret it) the section exists but the sectionHdl and sectionStr are not valid.

So how am I to copy [, create, and/or modify] these sections:

Sections with APIERR_BADPARS:
* API_SectAncestors
* API_SectCalledMacros
* API_SectInfoGIF

Sections with APIERR_NOLIBSECT:
* API_SectMigrTable
* API_SectCust_Keywords ('KWRD', this section is part of the section list but not part of the definitions, #define API_Sect...)
* API_SectCopyright

EDIT

I am also unable to find how to set/get values for the LibPart:
* Details > Author (see EDIT (2015 Aug 24))
* Details > Compatibility Options... (see EDIT (2015 Aug 19))

EDIT (2015 Aug 19)

I am now able to copy "Details > Compatibility Options..." via:
ACAPI_LibPart_GetDetails(oldLibPartIdx, &detl);
...
ACAPI_LibPart_SetDetails_ParamDef(&newLibPart, paramsHdl, &detl);
EDIT (2015 Aug 24)

Based on the binary data of the library, the "Details > Author" is part of the copyright section. But since there is an error, this is not saved. I also tried saving this binary data as GSHandle and call save section API, but still error.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
3 REPLIES 3
Akos Somorjai
Graphisoft
Graphisoft
ReignBough wrote:
I am trying to create a library from an existing one. What I did was just get all the information from the "source" library then copy (and modify) them. I am able to do this but limited to some section. Based on the documentation, ACAPI_LibPart_GetSection() will return APIERR_BADPARS for pictures, macros, etc.

I also followed the example given at the documentation of ACAPI_LibPart_GetSectionList(), modify it so that I will create a "destination" library.

When I called ACAPI_LibPart_GetSection(), I got APIERR_BADPARS and APIERR_NOLIBSECT on some of the sections. This means that the list that I got form ACAPI_LibPart_GetSectionList() have a "non-existing" section; or (as I interpret it) the section exists but the sectionHdl and sectionStr are not valid.

So how am I to copy [, create, and/or modify] these sections:

Sections with APIERR_BADPARS:
* API_SectAncestors
* API_SectCalledMacros
* API_SectInfoGIF

Sections with APIERR_NOLIBSECT:
* API_SectMigrTable
* API_SectCust_Keywords ('KWRD', this section is part of the section list but not part of the definitions, #define API_Sect...)
* API_SectCopyright

EDIT

I am also unable to find how to set/get values for the LibPart:
* Details > Author (see EDIT (2015 Aug 24))
* Details > Compatibility Options... (see EDIT (2015 Aug 19))

EDIT (2015 Aug 19)

I am now able to copy "Details > Compatibility Options..." via:
ACAPI_LibPart_GetDetails(oldLibPartIdx, &detl);
...
ACAPI_LibPart_SetDetails_ParamDef(&newLibPart, paramsHdl, &detl);
EDIT (2015 Aug 24)

Based on the binary data of the library, the "Details > Author" is part of the copyright section. But since there is an error, this is not saved. I also tried saving this binary data as GSHandle and call save section API, but still error.
Hi,

Why would you like to copy an existing library part? The copyright section is there for a reason

Best, Akos
ReignBough
Enthusiast
Akos wrote:
Why would you like to copy an existing library part? The copyright section is there for a reason 🙂
But you can modify them on the dialog and save it with the new copyright. So, I assume that these values can be copied and/or modified. Also, the "Author" of the libraries that I want to copy is us.

I just want to make a copy of the libraries and modify the contents, like adding parameter. So instead of adding this parameter on multiple libraries one by one, I just need to do it through an add-on.
~ReignBough~
ARCHICAD 26 INT (from AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Akos Somorjai
Graphisoft
Graphisoft
ReignBough wrote:
I just want to make a copy of the libraries and modify the contents, like adding parameter. So instead of adding this parameter on multiple libraries one by one, I just need to do it through an add-on.
If you don't have to do it on the fly, then you can use the LP_XMLConverter tool for that (part of the Library Developer Kit, accessible from the same place where you got the API DevKit from).
This tool converts the library parts to and from XML format; it's way much easier than doing it from an add-on.
We ourselves keep our own libraries in XML form.

Best, Akos
Learn and get certified!