Skip to content

Commit

Permalink
Add support for all Archicad categories (#2728)
Browse files Browse the repository at this point in the history
* Add support for all Archicad categories
* AC25 build fix
* build fix

---------

Co-authored-by: József L. Kiss <>
  • Loading branch information
jozseflkiss authored Jul 3, 2023
1 parent 2d03f13 commit ae7b29f
Show file tree
Hide file tree
Showing 41 changed files with 738 additions and 260 deletions.
2 changes: 2 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/AddOnMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Commands/GetWindowData.hpp"
#include "Commands/GetBeamData.hpp"
#include "Commands/GetColumnData.hpp"
#include "Commands/GetElementBaseData.hpp"
#include "Commands/GetObjectData.hpp"
#include "Commands/GetSlabData.hpp"
#include "Commands/GetRoomData.hpp"
Expand Down Expand Up @@ -195,6 +196,7 @@ static GSErrCode RegisterAddOnCommands ()
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetSubElementInfo> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetBeamData> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetColumnData> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetElementBaseData> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetObjectData> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetRoomData> ()));
CHECKERROR (ACAPI_Install_AddOnCommandHandler (NewOwned<AddOnCommands::GetRoofData> ()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "ClassificationImportManager.hpp"


ClassificationImportManager* ClassificationImportManager::instance = nullptr;

ClassificationImportManager* ClassificationImportManager::GetInstance ()
{
if (nullptr == instance) {
instance = new ClassificationImportManager;
}
return instance;
}


void ClassificationImportManager::DeleteInstance ()
{
if (nullptr != instance) {
delete instance;
instance = nullptr;
}
}


ClassificationImportManager::ClassificationImportManager () {}


GSErrCode AddToCache (GS::Array<API_ClassificationItem> items, GS::HashTable<GS::UniString, API_Guid>& cache)
{
for (auto& item : items) {
cache.Add (item.id, item.guid);

GS::Array<API_ClassificationItem> childrenItems;
GSErrCode err = ACAPI_Classification_GetClassificationItemChildren (item.guid, childrenItems);
if (err != NoError)
return err;

AddToCache (childrenItems, cache);
}

return NoError;
}


GSErrCode ClassificationImportManager::GetItem (const GS::UniString& systemName, const GS::UniString& code, API_Guid& itemGuid)
{
GS::ErrCode err = NoError;

if (!cache.ContainsKey (systemName)) {
API_ClassificationSystem targetSystem{};
{
GS::Array<API_ClassificationSystem> systems;
err = ACAPI_Classification_GetClassificationSystems (systems);
if (err != NoError)
return err;

err = Cancel;
for (auto& system : systems) {
if (system.name == systemName) {
targetSystem = system;
err = NoError;
break;
}
}

if (err != NoError)
return err;
}

GS::Array<API_ClassificationItem> rootItems;
err = ACAPI_Classification_GetClassificationSystemRootItems (targetSystem.guid, rootItems);
if (err != NoError)
return err;

GS::HashTable<GS::UniString, API_Guid> systemCache;
AddToCache (rootItems, systemCache);
cache.Add(systemName, systemCache);
}

if (cache[systemName].Get (code, &itemGuid))
return NoError;

return Error;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef CLASSIFICATION_IMPORT_MANAGER_HPP
#define CLASSIFICATION_IMPORT_MANAGER_HPP

#include "ModelInfo.hpp"

class ClassificationImportManager {
private:
static ClassificationImportManager* instance;

GS::HashTable< GS::UniString, GS::HashTable<GS::UniString, API_Guid>> cache;

protected:
ClassificationImportManager ();

public:
ClassificationImportManager (ClassificationImportManager&) = delete;
void operator=(const ClassificationImportManager&) = delete;
static ClassificationImportManager* GetInstance ();
static void DeleteInstance ();

GSErrCode GetItem (const GS::UniString& systemName, const GS::UniString& itemID, API_Guid& itemGuid);
};

#endif
Loading

0 comments on commit ae7b29f

Please sign in to comment.