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!

changing the index of library part does not work

Martin Walter
Enthusiast
I'm trying to change the library part index of an element by this code:


API_Element elementMask;
BNZeroMemory(&elementMask, sizeof(API_Element));

ACAPI_ELEMENT_MASK_SET(elementMask, API_WindowType, openingBase.libInd);
element.window.openingBase.libInd = iLibIndex;

const GSErrCode error = ACAPI_Element_ChangeParameters({ element.header.guid }, &element, nullptr, &elementMask);

const GSErrCode errorChange = ACAPI_Element_Change(&element, &elementMask, nullptr, 0UL, false);

But I get the result APIERR_BADPARS for both functions ACAPI_Element_ChangeParameters and ACAPI_Element_Change.
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Ralph Wessel
Mentor
I think that changing just the index of the library part may not be sufficient. You probably also need to set the correct parameters for that object – possibly that's what the error is indicating.

You could get the correct parameters by loading the default from the object with ACAPI_LibPart_GetParams. The memo data retrieved with this method can be directly used to update the target element, but you might want to use ACAPI_Element_Change in order to write the changes to both the element and memo data.
Ralph Wessel BArch

View solution in original post

5 REPLIES 5
Ralph Wessel
Mentor
Are you attempting to change the element within an active undo session? Otherwise, what error is returned?
Ralph Wessel BArch
Martin Walter
Enthusiast
Yes I use the command in ACAPI_CallUndoableCommand.

The returned error is APIERR_BADPARS.
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD
Martin Walter
Enthusiast
Any ideas?
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD
Solution
Ralph Wessel
Mentor
I think that changing just the index of the library part may not be sufficient. You probably also need to set the correct parameters for that object – possibly that's what the error is indicating.

You could get the correct parameters by loading the default from the object with ACAPI_LibPart_GetParams. The memo data retrieved with this method can be directly used to update the target element, but you might want to use ACAPI_Element_Change in order to write the changes to both the element and memo data.
Ralph Wessel BArch
Martin Walter
Enthusiast
Using the element memo instead of a nullptr was the correct hint. Thanks a lot!
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD
Learn and get certified!