License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

How to get thumbnail and parameters from external library part?

Anonymous
Not applicable
Hi everyone,


i'm tried from figure out to get thumbnail and parameters from external library part but failed.

For example :

	IO::Location fileLoc("C:\\Users\\W.C.SHIM\\Downloads\\test.gsm");
	API_LibPart      libPart;

	BNZeroMemory(&libPart, sizeof(API_LibPart));
	libPart.typeID = APILib_ObjectID;
	libPart.location = &fileLoc;
	ACAPI_LibPart_Register(&libPart);
but it doesnt work :'(

so... can i do this?
7 REPLIES 7
Ralph Wessel
Mentor
The quoted code should register the library part with ARCHICAD as part of the loaded library. Does that work, i.e. does it return NoError and is libPart.index non-zero?

If so, use the returned index to call ACAPI_LibPart_GetSectionList. The parameters, scripts and preview image are all stored in the returned sections. Each section has an ID for the data it contains, e.g. the parameters ID is API_SectParamDef and the preview image is API_SectInfoGIF.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
oooo... my mistake :'( i want load a .gsm file. not use part of the loaded library

(just open and use gsm file programmatically)

i tried ACAPI_LibPart_Create and ACAPI_LibPart_Register. but libpart.index is always 0.
Ralph Wessel
Mentor
Twily wrote:
oooo... my mistake :'( i want load a .gsm file. not use part of the loaded library
(just open and use gsm file programmatically)
i tried ACAPI_LibPart_Create and ACAPI_LibPart_Register. but libpart.index is always 0.
ACAPI_LibPart_Register effectively includes the gsm in the loaded library – you can't work with it otherwise. The value of libpart.index is the object's index in the loaded library.

Do you get an error code returned from ACAPI_LibPart_Register?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
ACAPI_LibPart_Register effectively includes the gsm in the loaded library – you can't work with it otherwise. The value of libpart.index is the object's index in the loaded library.

Do you get an error code returned from ACAPI_LibPart_Register?

I tried this :

	IO::Location fileLoc("C:\\Users\\W.C.SHIM\\Downloads\\test.gsm");
	API_LibPart      libPart;
	GSErrCode err = NoError;

	BNZeroMemory(&libPart, sizeof(API_LibPart));
	libPart.typeID = APILib_ObjectID;
	libPart.location = &fileLoc;
	err = ACAPI_LibPart_Register(&libPart);
	if (err != NoError)
	{
		char msgStr[256];
		sprintf(msgStr, "Register Error : %d", (int)err);
		ACAPI_WriteReport(msgStr, true);
	}

	err = ACAPI_LibPart_Create(&libPart);
	if (err != NoError)
	{
		char msgStr[256];
		sprintf(msgStr, "Create Error : %d", (int)err);
		ACAPI_WriteReport(msgStr, true);
	}
result is

Register Error : -2130313214
Create Error : -2130312314

I tried to find the error code but i can't find :'(
Ralph Wessel
Mentor
Twily wrote:
result is
Register Error : -2130313214
Create Error : -2130312314
I tried to find the error code but i can't find :'(
That error is APIERR_MEMFULL (Insufficient memory), which is odd. In what context are you trying to register the library part, e.g. in response to a menu item click?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
Twily wrote:
result is
Register Error : -2130313214
Create Error : -2130312314
I tried to find the error code but i can't find :'(
That error is APIERR_MEMFULL (Insufficient memory), which is odd. In what context are you trying to register the library part, e.g. in response to a menu item click?
yes, i'm testing to menu item click.
But later i will use immediately after open archicad.


I want this method (in automatically) :

after open archicad (load addon) ->
load gsm file ->
get thumbnail and parameters ->
close gsm file.
Ralph Wessel
Mentor
Twily wrote:
yes, i'm testing to menu item click.
But later i will use immediately after open archicad.
I want this method (in automatically) :
after open archicad (load addon) ->
load gsm file ->
get thumbnail and parameters ->
close gsm file.
That code should work in the right context – it looks practically identical to the documentation example. Perhaps try building one of the example projects – LibPart_Test – that uses this function. See if it works in that context and work back from there.
Ralph Wessel BArch
Software Engineer Speckle Systems