Documentation
About Archicad's documenting tools, views, model filtering, layouts, publishing, etc.
SOLVED!

developing an add-on on c++

noriksaroyan
Booster

Hey everyone!

I want to write a simple add-on on c++. I've downloaded necessities stated in https://github.com/GRAPHISOFT/archicad-addon-cmake and after going step-by-step through the docs I generated the c++ project, but it seems that I have some problems with including certain files like 

"APIEnvir.h"
"ACAPinc.h"
"ResourceIds.hpp"
"DGModule.hpp"
** attaching file with problems below **
Is there any github repos of an example add-on or any video material that can help me understand the c++ API? 
Thanks in advance!  

Screenshot 2023-07-18 at 17.51.28.png
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution
Joel Buehler
Enthusiast

hoho oh man, youre in for a ride! 😄 so buckle up, once you get a hang of it, you will love the endless possibilitys of the api 😉 

 

you need to get your start right. that means you need the following very important downloads before you can start:

 

- Dev Kit. You can get it here: 

https://archicadapi.graphisoft.com/downloads/api-development-kit

start with the archicad 26 version

 

- Cmake ready Template:

https://github.com/GRAPHISOFT/archicad-addon-cmake

 

on the githup page there is a step-by-step guide how to get it running. best thing is if you know some cmake, makes it a lot easier to understand waht is going on. you allready did that but it did not work. im not to sure if vs code even works. the cmake template creates a visual studio solution, with the ending *.sln

 

JoelBuehler_0-1689713470373.png

 

i cant see the sln in your folder. so i have to assume that the cmake command never worked. 

i suggest you use visual studio. 

 

 

waht can help you very well to understand the api are the following steps:

 

1. compile, read and understand all the examples you find in the dev kit 

they kinda suck, beacause they are so different in style and they are api testframework and example in one. but you learn a lot from those. 

you want do create some properties? boom, "Property_Test" shows you how its done.

the compiling part is very important, look how those examples work live in archicad. 

 

2. read the online documentation. go through the levels: 

Level 1: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel1

Level 2: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel2

Level 3: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel3

 

you dont need to read evrything, just the concepts to understand how the api works. 

 

And last, and this is really the last resort. you can look in the offline help you downloaded in the dev kit. but that help is nicley said a catastrophe.

the descriptions are very unclear, cluttered and so on. the examples are way better to get your hands on the "how-to-do-things"

View solution in original post

Solution

here is a little step by step guide with visual studio: 

 

download the cmake template and the dev-kit from the links above.

 

1 start a empty visual studio: 

 

JoelBuehler_1-1689713823643.png

 

2. Go to Open > cmake

 

JoelBuehler_2-1689713870760.png

 

3. choose your "CMakeLists.txt" 

 

JoelBuehler_3-1689713963928.png

 

4. open the cmake file. if you want to run your plugin not only in the demo version you can add here your dev id and the loc id from your developer account

 

JoelBuehler_4-1689714059233.png

 

5. Open the Powershell and check if the directory is right. you must be where your cmake file ist

this is sometimes for no reason wrong on my machine.

JoelBuehler_5-1689714191987.png

 

6. now comes the most unfun part. you need to get your cmake command right

 

JoelBuehler_6-1689714282970.png

 

first part is the visual studio version. it has to be right. look at the pinned post when you work with visual studio 2022 and not 2019 waht you have to install

https://community.graphisoft.com/t5/Developer-forum/Using-the-Development-Kit-with-Visual-Studio-202...

 

after that, its just where your dev kit is and which version it is

now youre ready to fire and you can press enter

 

7. when evrything went right, you should see the message "Build Files have been written to:"xxxx"

JoelBuehler_7-1689714521407.png

 

8. now you can close visual studio and open the visual studio solution:

 

JoelBuehler_8-1689714595825.png

9. when your newly created visual studio is open you can test out if evrything worked. for that you can build a plugin. for that click on "Add-on" and then "build"

 

JoelBuehler_9-1689714686846.png

 

10. In the output window visual studio should tell you that the build was succsessfull

 

JoelBuehler_10-1689714766572.png

 

11. Aaand here is the freshly created and ready to use Plugin-In

JoelBuehler_11-1689714806822.png

 

hope that helps a little bit 😃 

 

 

 

 

 

 

 

View solution in original post

7 REPLIES 7
Solution
Joel Buehler
Enthusiast

hoho oh man, youre in for a ride! 😄 so buckle up, once you get a hang of it, you will love the endless possibilitys of the api 😉 

 

you need to get your start right. that means you need the following very important downloads before you can start:

 

- Dev Kit. You can get it here: 

https://archicadapi.graphisoft.com/downloads/api-development-kit

start with the archicad 26 version

 

- Cmake ready Template:

https://github.com/GRAPHISOFT/archicad-addon-cmake

 

on the githup page there is a step-by-step guide how to get it running. best thing is if you know some cmake, makes it a lot easier to understand waht is going on. you allready did that but it did not work. im not to sure if vs code even works. the cmake template creates a visual studio solution, with the ending *.sln

 

JoelBuehler_0-1689713470373.png

 

i cant see the sln in your folder. so i have to assume that the cmake command never worked. 

i suggest you use visual studio. 

 

 

waht can help you very well to understand the api are the following steps:

 

1. compile, read and understand all the examples you find in the dev kit 

they kinda suck, beacause they are so different in style and they are api testframework and example in one. but you learn a lot from those. 

you want do create some properties? boom, "Property_Test" shows you how its done.

the compiling part is very important, look how those examples work live in archicad. 

 

2. read the online documentation. go through the levels: 

Level 1: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel1

Level 2: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel2

Level 3: 

https://archicadapi.graphisoft.com/documentation/api-white-paper#api_reference_chapterlevel3

 

you dont need to read evrything, just the concepts to understand how the api works. 

 

And last, and this is really the last resort. you can look in the offline help you downloaded in the dev kit. but that help is nicley said a catastrophe.

the descriptions are very unclear, cluttered and so on. the examples are way better to get your hands on the "how-to-do-things"

Solution

here is a little step by step guide with visual studio: 

 

download the cmake template and the dev-kit from the links above.

 

1 start a empty visual studio: 

 

JoelBuehler_1-1689713823643.png

 

2. Go to Open > cmake

 

JoelBuehler_2-1689713870760.png

 

3. choose your "CMakeLists.txt" 

 

JoelBuehler_3-1689713963928.png

 

4. open the cmake file. if you want to run your plugin not only in the demo version you can add here your dev id and the loc id from your developer account

 

JoelBuehler_4-1689714059233.png

 

5. Open the Powershell and check if the directory is right. you must be where your cmake file ist

this is sometimes for no reason wrong on my machine.

JoelBuehler_5-1689714191987.png

 

6. now comes the most unfun part. you need to get your cmake command right

 

JoelBuehler_6-1689714282970.png

 

first part is the visual studio version. it has to be right. look at the pinned post when you work with visual studio 2022 and not 2019 waht you have to install

https://community.graphisoft.com/t5/Developer-forum/Using-the-Development-Kit-with-Visual-Studio-202...

 

after that, its just where your dev kit is and which version it is

now youre ready to fire and you can press enter

 

7. when evrything went right, you should see the message "Build Files have been written to:"xxxx"

JoelBuehler_7-1689714521407.png

 

8. now you can close visual studio and open the visual studio solution:

 

JoelBuehler_8-1689714595825.png

9. when your newly created visual studio is open you can test out if evrything worked. for that you can build a plugin. for that click on "Add-on" and then "build"

 

JoelBuehler_9-1689714686846.png

 

10. In the output window visual studio should tell you that the build was succsessfull

 

JoelBuehler_10-1689714766572.png

 

11. Aaand here is the freshly created and ready to use Plugin-In

JoelBuehler_11-1689714806822.png

 

hope that helps a little bit 😃 

 

 

 

 

 

 

 

Hey, Joel. Thanks for the information.

I've read the whole thread and got pretty good understanding of how it should be and yes, probably, I got something wrong with cmake.  I'm using macOS so using visual studio for this one is pretty much impossible. Is there any information for macOS users(yep, I know that using macOS isn't the brightest idea of them all, haha) 

Thanks in advance! 

after i wrote my post i thought: waht if he's a mac user? 😄 

im sorry i cant help to far with XCode on a Mac. it is my understanding that you also need the dev kit. And the cmake create command also needs to be perfect. it could help if you show your cmake error messages. 

 

furhtermore about developing on mac: im not to sure if this a bad idea, since most of archicad users i know are using a mac. so to be able to create and test a plugin in a environment that comes very close to the real deal isn't a bad idea at all. im thinking about to get a mac or at least a virtual machine to test my plugins on a mac. 

Well, the good news is I found a windows pc and now I can do this one on windows. 

Mac is convenient for many things, but since microsoft are so stubborn and dont want to share anything with macOS users, we have to improvise to survive haha. 

Thanks for your help, ill try to implement everything above on my end. If anything goes south, I'll just return to this thread))

Have a great one!

Hi, Joel Buehler

In step 6, I got error like this. " Failed to detect Archicad version, please check the value of the AC_API_DEVKIT_DIR variable." 

Can you help me fix it? 

 

Thank you2023-08-22_15-34-12.png

PREVIEW
 
 
 

hehey tranthanhlo, i think its just a error in the directory link. i just built an add-on and i had to add "\Support" to the directory uri. 

should look something like this: 

 

""C:\Program Files\API Development KIT 26.3000\Support"

 

does it work with an "Support"?