-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving API name/type changes in different versions #33
Comments
I've worked around this by adding the following to if (DEFINED ADDITIONAL_COMPILE_DEFINITIONS)
add_compile_definitions(${ADDITIONAL_COMPILE_DEFINITIONS})
endif() Subsequently if using the python build tools, it can be used in the following way: And then in code as #if ARCHICAD_27
...
#endif |
Sorry for the late reply. We cannot at the moment provide source level compatibility between API versions. We have things in the API that in retrospect shouldn't have been exposed, so we are slowly cleaning up the API. One recommendation or best practice here would be to create a wrapper around required parts of the API in a way that decouples your addon logic from the API or at least makes the addon logic not tightly coupled to the API. To detect the API version in the addon source, you may set the appropriate definition and compile conditionally using that: # In CMakeLists.txt
GenerateAddOnProject (CMakeTarget ...)
target_compile_definitions (CMakeTarget PRIVATE "ARCHICAD_API=${AC_VERSION}") /* In a C++ file */
#if ARCHICAD_API == 24
// Code for only Archicad 24
#elif ARCHICAD_API == 25 || ARCHICAD_API == 26
// Code for Archicad 25 and 26
#elif ARCHICAD_API == 27
// Code for only Archicad 27
#endif Once a new Archicad version's Release Candidate is made available, you will also have a new devkit that you can use to port your addon if necessary. |
Hello! Thanks for this template. It's been very useful to get started on a plugin.
I started with this template, then have copied in most of the BrowserControl example. I noticed when doing this that the builds started failing for Archicad 25 and 26. This appears to be for a few reasons, but all of them seem to be namespace or function name changes.
For example,
ACAPI_Register_Menu
in AC26 vs.ACAPI_MenuItem_RegisterMenu
in AC27.Similarly, the JS object classes were formerly
DG::JSValue
and are nowJS::Value
.I am relatively new to C++. Is there a technique for using different names based on AC version? It would be convenient to be able to target multiple out of one project.
Coming from C# the equivalent would be:
Edit: Looking at this again it seems like quite a bit of work to manage multiple versions as the API seems to have changed a reasonable amount (at least by naming convention) between AC26 and AC27
The text was updated successfully, but these errors were encountered: