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

User avatar
By poco2013
#287129
The Xcode Add On Template is great to get started but lacks the menu 'hook-up' necessary to start a project. This kind of defeats the propose of a quick start template.

Would like to see a template that includes a simple test menu with say one item/function and the standard 'Hello World' WriteReport message.

Are there any instruction available as how to create my own template in xcode to do this?
User avatar
By kzaremba
#287140
It would be good to have one for Visual Studio as well. So you can start project instantly on custom path. :D
User avatar
By Hai SAGI-VIZ
#287166
It would be good to have one for Visual Studio as well. So you can start project instantly on custom path. :D
I'm using VS 2017 but I don't know how to start with Hello World Blog. How can I use that code and necessary resource to get Hello World in AC. Could you show me how to do it step by step? Thanks for your kind.
User avatar
By Ralph Wessel
#287178
I suggest copying one of the example projects with a single menu item, e.g. AddOnObject_Manager and replace the code in the menu handler:
Code: Select all// ----------------------------------------------------------------------------- // DoCommand // called to perform the user-asked command // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *params) { if (params->menuItemRef.itemIndex == 1) { //Your code here } return NoError; } // MenuCommandHandler
User avatar
By Ralph Wessel
#287206
Thank you so much but I'm a beginner and sorry I don't understand where menu handler is. :(
Search the project for MenuCommandHandler. For that particular project, it's in the file AddOnObject_Manager.cpp
User avatar
By Akos Somorjai
#287278
Hi Ralph,
Thank you so much but I'm a beginner and sorry I don't understand where menu handler is. :(
So, in your RegisterInterface() function:
Code: Select allGSErrCode __ACENV_CALL RegisterInterface (void) { ACAPI_Register_Menu (32500, 0, MenuCode_UserDef, MenuFlag_Default); return NoError; } // RegisterInterface
Here 32500 is the ID of the string resource that appears in the menu; add this to the .grc file:
Code: Select all'STR#' 32500 "Strings for the Menu" { /* [ 1] */ "Hello world" }
Then in your Initialize() function add the following:
Code: Select allGSErrCode __ACENV_CALL Initialize (void) { GSErrCode err = ACAPI_Install_MenuHandler (32500, MenuCommandHandler); // other stuff }
Last, in your MenuCommandHandler function call Do_CreateHelloWord():
Code: Select allGSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *params) { if (params->menuItemRef.itemIndex == 1) { Do_CreateHelloWord (); } }
User avatar
By Hai SAGI-VIZ
#287303
Search the project for MenuCommandHandler. For that particular project, it's in the file AddOnObject_Manager.cpp
Thank you very much. I will learn it and reply for result as soon.
User avatar
By Hai SAGI-VIZ
#287305
Hi Akos,
Thank you very much for the detailed guide for me. It's very helpful for the beginner like me.

P/S: Thanks for Ralph, I can build more example without any errors and maybe I knew how API work and folder structure. Thank so much for supporting. I will do something by myself ^.^