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

Non-blocking behavior

Anonymous
Not applicable
Hello there, I'm trying to find an operation that allows the user to freely use the GUI while my plug-in is running.

For example, my plug-in starts by clicking on a button on the top menu, after that it establishes a connection with another application, and I want the user to be able to use the GUI while that connection is maintained by the plug-in.
Currently I have a loop that peeks into the communication channel to know if there is something do, if not it continues trying. This is where I would like the ability to allow the user to freely use the GUI.

Does anyone know if there is a way to achieve this functionality?

Thank you in advance.
9 REPLIES 9
stefan
Expert
We have the same goal in our plug-in. It seems technically possible (see the ArchiCAD-Grasshopper connection). However, the documentation to develop something similar is very limited.

One thing is ensuring the Add-on stays in memory, so it is not unloaded after you executed a command. The other thing is that I'm informed that it becomes really tricky as the underlying ArchiCAD database can be updated at any moment.

We have tried with launching a small server application in a separate thread. So far, it works, but we are unsure about stability, so it would be good to see others sharing their experiences.
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad27/Revit2023/Rhino8/Unity/Solibri/Zoom
MBP2023:14"M2MAX/Sonoma+Win11
Archicad-user since 1998
my Archicad Book
Oleg
Expert
Some ideas:

1. You may to create a Palette dialog.
Progress bar and Cancel button for example.
Imptement the PanelObserever::PanelIdle event.
Show it during you process active.
Do the communication action in this event.
Close the panel as the communication ends

2. For AC19.
Look at ACAPI_Command_CallFromEventLoop command.
See the example in the documentation about this command and GS::Thread.
Ralph Wessel
Mentor
Xylios wrote:
Hello there, I'm trying to find an operation that allows the user to freely use the GUI while my plug-in is running.
The current problem is that many ARCHICAD API calls are not designed for concurrency, especially database writes, i.e. undoable transactions. I don't what might happen with read-only operations if they run in parallel with user-editing, file merges, TW receives etc.

Until GS advises otherwise, I'd aim for processes where the add-on is legitimately called by ARCHICAD rather than aiming for full concurrency. The suggestions from Oleg are 2 possibilities. You're essentially aiming to fit in with ARCHICAD's main event-handling loop rather than running in parallel to it.
Ralph Wessel BArch
stefan
Expert
Oleg wrote:
Some ideas:

1. You may to create a Palette dialog.
Progress bar and Cancel button for example.
Imptement the PanelObserever::PanelIdle event.
Show it during you process active.
Do the communication action in this event.
Close the panel as the communication ends

2. For AC19.
Look at ACAPI_Command_CallFromEventLoop command.
See the example in the documentation about this command and GS::Thread.
Thank you Oleg. We have tried with example 2, but unfortunately, the GS:Thread and GS::Runnable classes mentioned in the example are not recognised. Are they part of the API? Or did they change with ArchiCAD 19? Strange that an included example would use non-documented classes... We will try further with an alternative class or starting our own thread, but fear that it will lead to the same limitations, if not fully steered from the ArchiCAD main thread.
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad27/Revit2023/Rhino8/Unity/Solibri/Zoom
MBP2023:14"M2MAX/Sonoma+Win11
Archicad-user since 1998
my Archicad Book
Oleg
Expert
I didnt use the GS::Thread. It was a just idea.
Key point is ACAPI_Command_CallFromEventLoop (see the Ralph's comment about main event loop ).
I think you can to try native threads.

GS:Thread and GS::Runnable classes included in the GSRoot module of AC19.
And yes, It is undocumented unfortunately.
stefan
Expert
OK. Thank you for clarification.

We did a test with boost threading and that seemed to work for now. Need further testing.

Thanks Oleg and Ralph for sharing your insights.
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad27/Revit2023/Rhino8/Unity/Solibri/Zoom
MBP2023:14"M2MAX/Sonoma+Win11
Archicad-user since 1998
my Archicad Book
Ralph Wessel
Mentor
stefan wrote:
We did a test with boost threading and that seemed to work for now. Need further testing.
I've used GS::Runnable, but only in the context of the element settings dialogs.
Ralph Wessel BArch
Anonymous
Not applicable
Hello there, sorry for only posting today. I have been busy with writing my thesis.

Anyway, thank you for all the replies.

I tried creating a panel, with a panel manager, following an example I found on this forum, http://archicad-talk.graphisoft.com/viewtopic.php?t=49587

I implemented the PanelIdle to do the communication, but the palette never received any idle events. I also tested it using the panel resize events, although it received the events correctly, it would block ArchiCAD.

After that, I decided using a simple C++ thread, and it seems to be working, at least for my purposes. However, I will still need to do more testing.

Once again, thank you for the help.
Anonymous
Not applicable
Any updates regarding this topic?