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

How to click an Element and paint corresponding overridable attribute

mats1
Contributor

Hi all, i would like to create a tool where users can select attributes (materials) and paint them onto elements of their choosing. The problem i am having right now is that when using

 

 

 

 

 

ACAPI_Notification_CatchSelectionChange

 

 

 

 

 

 

 

 

 

 

 

static GSErrCode SelectionChangeHandler(const API_Neig* selElemNeig) {

    // Pseudo code
    if (selElemNeig->neigID != APINeig_None) {
        auto err = ACAPI_CallUndoableCommand("Change element", []() {
            return ACAPI_Element_Change(...);
        });
        // err is Unkown Error when printed
        // after this the SelectionChangeHandler is being called repeatedly indefinitely
    }
    else
        ACAPI_WriteReport("All elements deselected", false);

    return NoError;
}   // SelectionChangeHandler

 

 

 

 

 

 I am unable to update the element inside of the callback, im guessing based of the docs its not allowed to do DB operations on a seperate thread.

I also tried using 

 

 

 

 

 

        API_Neig clickedNeig;

        ClickAnElem("Click an elem to select/deselect", API_ZombieElemID, &clickedNeig);

        auto err = ACAPI_CallUndoableCommand("Change element", []() {
            return ACAPI_Element_Change(...);
            });

 

 

 

 

 

Which works but i want to be able to select many things and paint accordingly. having this solution in a while loop ofcourse blocks the UI so the user cannot interact with other panels visible until ESC key is pressed. I have buttons in my to stop painting or changing colors.


11 REPLIES 11
mats1
Contributor

I have one more question regarding this topic that i hope someone can answer. 

When i use ACAPI_UserInput_GetPoint on the ref side of a wall the ipgon of API_GetPointType is accurate to the refInd on the Element if i use ACAPI_Element_Get on the clicked wall. Now my question is this, if i add a window to this wall and click the same side, then the ipgon is changed but not the refInd. How can i accurately get if the user clicked on the reference side (or any side where i can override the material for that matter)?

mats1
Contributor

[removed this reply]