We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
Wednesday
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.
Thursday
Does this have to be an API solution?
Can you just use the surface painter tool that is already there in Archicad?
Barry.
Thursday - last edited Thursday
Hi, unfortunately this is not possible since i want to both create the colors and paint them in the same palette. I understand the surface painter is exactly for picking colors and painting elements but i would like to create my own, and it seems to be impossible with the available APIs.
Mats.
yesterday
This is now resolved. The trick was when we changed the element the user had selected this function was called again and became an infinite repeating loop. Checking if the same element was updated twice solved it.
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