2021-10-17 09:33 PM
I made a small open source add-on for synchronizing properties and parameters of GDL objects. It works in version 24, but I would like to release an add-on for other versions. What is the best way to organize the assembly and testing of an add-on for different versions of Archicad (provided that the code is compatible with other versions)?
Structural engineer, developer of free addon for sync GDL param and properties
Solved! Go to Solution.
2021-10-18 07:36 AM - edited 2021-10-19 07:32 PM
Archicad API is relatively stable, but sometimes there are changes that won't compile with a newer version of the Development Kit. The question here is how to handle this situation.
There are two ways:
The selected solution depends on your code. If you have relatively small codebase the second one is recommended. You can have compiler flags to determine the version of base Archicad, so you can write something like this:
#if defined (ServerMainVers_2500)
using MemoryIChannel = GS::MemoryIChannel;
using MemoryOChannel = GS::MemoryOChannel;
#else
using MemoryIChannel = IO::MemoryIChannel;
using MemoryOChannel = IO::MemoryOChannel;
#endif
or this:
void SetAPIElementType (API_Element& element, API_ElemTypeID elemTypeId)
{
#ifdef ServerMainVers_2600
element.header.type = API_ElemType (elemTypeId);
#else
element.header.typeID = elemTypeId;
#endif
}
This is how the Maze Generator Add-On is implemented.
From the build point of view I would generate projects with cmake to different folders inside the Build folder (like Build/AC24 and Build/AC25). With this solution you will have separate projects for the same code base.
2021-10-18 07:36 AM - edited 2021-10-19 07:32 PM
Archicad API is relatively stable, but sometimes there are changes that won't compile with a newer version of the Development Kit. The question here is how to handle this situation.
There are two ways:
The selected solution depends on your code. If you have relatively small codebase the second one is recommended. You can have compiler flags to determine the version of base Archicad, so you can write something like this:
#if defined (ServerMainVers_2500)
using MemoryIChannel = GS::MemoryIChannel;
using MemoryOChannel = GS::MemoryOChannel;
#else
using MemoryIChannel = IO::MemoryIChannel;
using MemoryOChannel = IO::MemoryOChannel;
#endif
or this:
void SetAPIElementType (API_Element& element, API_ElemTypeID elemTypeId)
{
#ifdef ServerMainVers_2600
element.header.type = API_ElemType (elemTypeId);
#else
element.header.typeID = elemTypeId;
#endif
}
This is how the Maze Generator Add-On is implemented.
From the build point of view I would generate projects with cmake to different folders inside the Build folder (like Build/AC24 and Build/AC25). With this solution you will have separate projects for the same code base.
2021-10-20 04:38 AM - edited 2021-10-20 04:45 AM
We use #2 on the recommended solution. We started on AC18 and currently AC25. But we currently supporting AC21 above (since our current projects use these versions). Whenever new AC version is/will be released, we made sure that the add-ons that we have will be compatible to that new version.
If ever you will be supporting lower version of AC (below 24 in your op), I recommend you to start to the lowest version first, then go up to the latest version. When we have new add-on, we define which AC versions will be supported, and start coding to the lowest version. After completing the add-on (or even one functionality of it), we start migrating to the next version and change anything that might conflict to the newer version (renamed functions, new functions, removed/obsolete functions, etc.).