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] From .gsm file to embedded library

Miha Nahtigal
Advocate
What would be the best way to store a .gsm file as a new API_LibPart object in embedded library?

Is it possible to fill LibPart sections from gsm file?

Currently I am adding a new linked library APIEnv_AddLibrariesID, search for object by name with ACAPI_LibPart_Search and copy sections manually to a new libpart created with ACAPI_LibPart_Create... which is a bit tedious, besides I cannot remove linked /tmp/ library.
BIMquants.comBETA - Quantities and Costs Estimation with Archicad AddOn :: rushing to publish a beta preview
2 REPLIES 2
Miha Nahtigal
Advocate
Found a solution:
IO::Location rab("C:/GDLTest/11204.gsm");

	GSErrCode err;
	auto folderId = API_SpecFolderID::API_EmbeddedProjectLibraryFolderID;

	IO::Location embeddedLibraryFolder;

	if (ACAPI_Environment(APIEnv_GetSpecFolderID, &folderId, &embeddedLibraryFolder) == NoError && IO::Folder(embeddedLibraryFolder).GetStatus() == NoError) {
		// copy file to embedded folder
		IO::Location destFolder = embeddedLibraryFolder;
		destFolder.AppendToLocal(IO::Name("11204.gsm"));

		err = IO::fileSystem.Copy(rab, destFolder);

		API_LibPart libPart;
		BNZeroMemory(&libPart, sizeof(API_LibPart));

		libPart.typeID = APILib_ObjectID;
		libPart.location = &destFolder;

		err = ACAPI_LibPart_Register(&libPart);

	}
BIMquants.comBETA - Quantities and Costs Estimation with Archicad AddOn :: rushing to publish a beta preview
Akos Somorjai
Graphisoft
Graphisoft
vuego wrote:
Found a solution:
...
Alternatively, you can create a new library part (ACAPI_LibPart_Create), that puts it directly into the embedded library. Also, you can assemble the library part with ACAPI_LibPart_AddSection or ACAPI_LibPart_NewSection calls.

Best, Akos
Learn and get certified!