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

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
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

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!