cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Catch project event right from Archicad startup (without user input)

LVirone Greisch
Booster

Hello,

 

I'm exploring whether it's possible to catch Archicad events right from Archicad startup, rather than only after triggering a command via the MenuCommandHandler method.

 

I've been using the methods Do_CatchProjectEvent and NotificationHandler from the sample Project_Observer.cpp provided in the API Development Kit 28.4001\Examples\Notification_Manager. Currently, I'm calling Do_CatchProjectEvent within the RegisterInterface method, but it doesn't seem to work. Specifically, the dialog triggered by ACAPI_WriteReport in NotificationHandler never appears.

 

It does work when I call Do_CatchProjectEvent from within a command in MenuCommandHandler.

 

My ultimate goal is to have Archicad generate LibraryPart (GSM) files in response to requests from an external application. To do this, I want to launch Archicad automatically and determine when it's safe to begin code execution for GSM generation (ensuring Archicad isn't busy to avoid any potential crashes). Maybe there is a method to ask Archicad if the environment is safe?

 

Thanks

Virone Lorenzo
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

Hi Lorenzo,

 

You need to call ACAPI_ProjectOperation_CatchProjectEvent (which is the function call in Do_CatchProjectEvent you were referring to) inside of the Initialize function. Calling it in RegisterInterface doesn't work.

 

I think the "earliest" notification you can get are APINotify_New, APINotify_NewAndReset and APINotify_Open. So whenever a project is opened/newly created.

 

 

For your ultimate goal I have two suggestions/questions:

  1. Have you considered using the LPXML_Converter? This could be used and triggered independent of Archicad to create GSM files. When you load the folder where the GSM files are created as a library, then you just need to ReloadLibraries (could also be triggered by an external program) and you have the GSM file available in the AC project.
    This wouldn't work so easily if you need information from inside the AC plan file to create the GSM file. But if that's not the case, this approach might be easier.
  2. Are you aware of the Communication Module? It's called "Add-On - Add-On" communication, but commands registered that way can also be triggered via Archicads JSON interface. That's basically how you can extend the Python API and also how e.g. TAPIr works behind the scenes.

 

Hope that helps,
Bernd

View solution in original post

Solution
Oleg
Expert

Hi,

In addition. 
If you want to load an addon at start of archicad, you need to return APIAddon_Preload from CheckEnvirinment function.

PS: 
And there is related function ACAPI_KeepInMemory. 
I think, calls of ACAPI_ProjectOperation_CatchProjectEvent in the Initialize function will keep the addon in memory already.
So in this case just for info.

View solution in original post

6 REPLIES 6
Solution

Hi Lorenzo,

 

You need to call ACAPI_ProjectOperation_CatchProjectEvent (which is the function call in Do_CatchProjectEvent you were referring to) inside of the Initialize function. Calling it in RegisterInterface doesn't work.

 

I think the "earliest" notification you can get are APINotify_New, APINotify_NewAndReset and APINotify_Open. So whenever a project is opened/newly created.

 

 

For your ultimate goal I have two suggestions/questions:

  1. Have you considered using the LPXML_Converter? This could be used and triggered independent of Archicad to create GSM files. When you load the folder where the GSM files are created as a library, then you just need to ReloadLibraries (could also be triggered by an external program) and you have the GSM file available in the AC project.
    This wouldn't work so easily if you need information from inside the AC plan file to create the GSM file. But if that's not the case, this approach might be easier.
  2. Are you aware of the Communication Module? It's called "Add-On - Add-On" communication, but commands registered that way can also be triggered via Archicads JSON interface. That's basically how you can extend the Python API and also how e.g. TAPIr works behind the scenes.

 

Hope that helps,
Bernd

Solution
Oleg
Expert

Hi,

In addition. 
If you want to load an addon at start of archicad, you need to return APIAddon_Preload from CheckEnvirinment function.

PS: 
And there is related function ACAPI_KeepInMemory. 
I think, calls of ACAPI_ProjectOperation_CatchProjectEvent in the Initialize function will keep the addon in memory already.
So in this case just for info.

Hi @BerndSchwarzenbacher,

 

Thanks for your very useful informations ! The LPXML_Converter is the perfect tool for what I need, I don't even need to "pilot" Archicad !

 

Is it possible to debug GDL script using LPXML_Converter ?

 

Hi@Oleg,

Thank you for your useful addition !

Virone Lorenzo

Glad to read that the information helps you 🙂

 

Unfortunately the LPXML_Converter can't really be used for debugging scripts to my understanding.

 

If you end up using it, I recommend to use the "hsf" format. I think it's the easiest to work with.

Hello again @BerndSchwarzenbacher,

 

There is no debugger in LPXML_Converter, but is there a way to debug GDL I write using Archicad API with ACAPI_LibraryPart_WriteSection ?

 

Globally, is there a way to debug GDL script using code ?

 

Thank you

Virone Lorenzo

I don't think there is any unfortunately! At least I'm not aware of any.