The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Barry Kelly, Karl Ottenstein, LaszloNagy, ejrolon, gkmethy, Tibor Lorántfy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik

By Xylios
#248671
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.
User avatar
By stefan
#249543
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.
User avatar
By Oleg
#249547
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.
User avatar
By Ralph Wessel
#249613
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.
User avatar
By stefan
#249813
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.
User avatar
By Oleg
#249823
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.
User avatar
By stefan
#249856
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.
User avatar
By Ralph Wessel
#249874
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.
By Xylios
#249951
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/vie ... hp?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.