We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

How to edit parameters of the element on the scene

Anonymous
Not applicable
Seems like this piece of code is getting lights from the scene correctly, but the values are not saved into objects. What else am I supposed to do in order to change parameters on the element?
Thanks for the help.
 
GS::Array<API_Guid> elemList;
        ACAPI_Element_GetElemList(API_LampID, &elemList, APIFilt_OnActFloor, APIVarId_Light, APINULLGuid);
        for (const auto& e : elemList) {
            API_Element element;
            BNZeroMemory(&element, sizeof(API_Element));
            element.header.guid = e;
            if (ACAPI_Element_Get(&element, 0) == NoError) {
                element.lamp.lightColor = API_RGBColor{ 1.f, 0.f, 0.f };
                element.lamp.lightIsOn  = true;
            }
        }
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Ralph Wessel
Mentor
Use ACAPI_Element_Change to write the change back to the database.
Ralph Wessel BArch
Software Engineer Speckle Systems

View solution in original post

2 REPLIES 2
Solution
Ralph Wessel
Mentor
Use ACAPI_Element_Change to write the change back to the database.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Thanks! To make this post more helpful, you have to wrap the actual element changing logic into ACAPI_CallUndoableCommand because in another case you get APIERR_NEEDSUNDOSCOPE and no changes will occur.