2024-11-13 04:27 PM - edited 2024-11-26 11:48 AM
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.
2024-11-14 02:14 AM
Does this have to be an API solution?
Can you just use the surface painter tool that is already there in Archicad?
Barry.
2024-11-14 08:08 AM - edited 2024-11-14 08:09 AM
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.
2024-11-15 11:38 AM
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
2024-11-20 11:45 AM
Hi,
I am currently working on a project in ArchiCAD 28, and I am trying to create a functionality similar to the Surface Painter tool. The goal is to apply colors or materials to objects by clicking on them, but only applying the color to the specific parts I click on—just like how Surface Painter works.
Here’s what I want to achieve:
I’ve been exploring the ArchiCAD API, but I’m unsure of the best approach to get this specific behavior. Can anyone provide insights into how I can capture mouse clicks on objects or surfaces and apply materials to the specific part clicked?
Any help, code snippets, or guidance would be greatly appreciated!
Thanks in advance!
2024-11-20 01:58 PM
Personly, i'm a soft user, i use directly a gdl object with associated texture for painting wall if there are differrent painting on the wall like different color in bottom part and top part,or atistitic painting on dwelling building.
Please excuse my english.I have base, but i don't practice usually in office.
2024-11-20 02:44 PM - edited 2024-11-20 02:59 PM
Hi,
im not sure i understand how a gdl object works. Are you painting based on selection or are you creating your own objects with respective paintings. I.e are you detecting user clicks and painting accordingly?
2024-11-20 03:05 PM
i define a surface by gdl standard vertex associate to surface, with a maximum of point.for the moment i use only for planar surface.You just have to put dhe object on the plane with a normal vector to the surface with a very small distance in order to have no confusion of surface between the structural surface(metal,concrete,wood panel).
with the primitive elements include body command.
(vert teve vect edge,pgon body base and material....)
you have 1024 parameters in a basic object, to help you.
actually i think the problem is about how to improve the gdl interface,like import and create parameters via excel like a "list of elements"..
and test each view inside.
2024-11-20 03:41 PM
Am i understanding this correctly. For you to paint an object you create a new surface very close along the normal vector of the original surface?
I was thinking of modifying the existing one, do you know how would this be possible using the c++ apis?
2024-11-21 10:26 AM
Just use the form tool above the wall, and manage your draft by note the color RGB,define by color or photoshop.
more simple.and have a special ID for painting ,and the price to associate with.
Aikido, omote and oura.
and for more complicated form you use verpex and mapping like painting under a dome in Toscane, if its original painting or mapping the texture to go fast.
its a fast example in the pictures under .Mapping its the fast way when picture already exist.