Skip to content

Commit

Permalink
bug(Archicad): Element type names in Archicad 25 (#2740)
Browse files Browse the repository at this point in the history
Element type names in Archicad 25

Co-authored-by: József L. Kiss <>
  • Loading branch information
jozseflkiss authored Jul 7, 2023
1 parent 1924735 commit b5bc2a6
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GS::ErrCode GetElementBaseData::SerializeElementType (const API_Element& elem,
return err;

// Positioning
API_StoryType story = Utility::GetStory (elem.beam.head.floorInd);
API_StoryType story = Utility::GetStory (elem.header.floorInd);
os.Add (ElementBase::Level, Objects::Level (story));

return NoError;
Expand Down
1 change: 1 addition & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/ResourceIds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define ID_ADDON_MENU 32500
#define ID_DEFAULT_STORY_FORMAT 32800
#define ID_LOG_MESSAGES 33000
#define ID_ELEMENT_TYPE_STRINGS 34000

#define ID_LOG_MESSAGE_LIBPART_SEARCH_ERROR 1
#define ID_LOG_MESSAGE_ATTRIBUTE_SEARCH_ERROR 2
Expand Down
27 changes: 27 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/ResourceStrings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "ResourceStrings.hpp"

#include "ResourceIds.hpp"

// from GSRoot
#include "RS.hpp"

//from API
#include "ACAPinc.h"


template<class EnumType>
const GS::UniString& TGetStringFromResource (const int& resourceID, const EnumType& resourceItemId)
{
static GS::HashTable<EnumType, GS::UniString> resourceStringCache;

if (!resourceStringCache.ContainsKey (resourceItemId))
resourceStringCache.Add (resourceItemId, RSGetIndString (resourceID, (UInt32) resourceItemId, ACAPI_GetOwnResModule ()));

return resourceStringCache.Get(resourceItemId);
}


const GS::UniString& ResourceStrings::GetElementTypeStringFromResource (const ElementTypeStringItems& resourceItemId)
{
return TGetStringFromResource<ResourceStrings::ElementTypeStringItems> (ID_ELEMENT_TYPE_STRINGS, resourceItemId);
}
90 changes: 90 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/ResourceStrings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#ifndef RESOURCE_STRINGS_HPP
#define RESOURCE_STRINGS_HPP

#include "UniString.hpp"


namespace ResourceStrings {

enum class ElementTypeStringItems {
WallString = 1,
ColumnString,
BeamString,
WindowString,
DoorString,
ObjectString,
LampString,
SlabString,
RoofString,
MeshString,
DimensionString,
RadialDimensionString,
LevelDimensionString,
AngleDimensionString,
TextString,
LabelString,
ZoneString,
HatchString,
LineString,
PolyLineString,
ArcString,
CircleString,
SplineString,
HotspotString,
CutPlaneString,
CameraString,
CamSetString,
GroupString,
SectElemString,
DrawingString,
PictureString,
DetailString,
ElevationString,
InteriorElevationString,
WorksheetString,
HotlinkString,
CurtainWallString,
CurtainWallSegmentString,
CurtainWallFrameString,
CurtainWallPanelString,
CurtainWallJunctionString,
CurtainWallAccessoryString,
ShellString,
SkylightString,
MorphString,
ChangeMarkerString,
StairString,
RiserString,
TreadString,
StairStructureString,
RailingString,
RailingToprailString,
RailingHandrailString,
RailingRailString,
RailingPostString,
RailingInnerPostString,
RailingBalusterString,
RailingPanelString,
RailingSegmentString,
RailingNodeString,
RailingBalusterSetString,
RailingPatternString,
RailingToprailEndString,
RailingHandrailEndString,
RailingRailEndString,
RailingToprailConnectionString,
RailingHandrailConnectionString,
RailingRailConnectionString,
RailingEndFinishString,
AnalyticalSupportString,
AnalyticalLinkString,
BeamSegmentString,
ColumnSegmentString,
OpeningString
};

const GS::UniString& GetElementTypeStringFromResource (const ElementTypeStringItems& resourceItemId);

}

#endif
89 changes: 85 additions & 4 deletions ConnectorArchicad/AddOn/Sources/AddOn/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ObjectState.hpp"
#include "FieldNames.hpp"
#include "TypeNameTables.hpp"
#include "ResourceIds.hpp"
#include "ResourceStrings.hpp"
using namespace FieldNames;

namespace Utility {
Expand Down Expand Up @@ -38,9 +38,90 @@ GS::ErrCode GetTypeNameFromElementType (const API_Elem_Head& header, GS::UniStri
#ifdef ServerMainVers_2600
return ACAPI_Goodies_GetElemTypeName (header.type, typeName);
#else
UNUSED (header);
typeName = "Archicad Element"; // ACAPI_Goodies_GetElemTypeName not implemented in Archicad 25
return NoError;
ResourceStrings::ElementTypeStringItems elementTypeStringItems;
switch (header.typeID) {
case API_WallID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::WallString; break;
case API_ColumnID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ColumnString; break;
case API_BeamID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::BeamString; break;
case API_WindowID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::WindowString; break;
case API_DoorID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::DoorString; break;
case API_ObjectID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ObjectString; break;
case API_LampID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::LampString; break;
case API_SlabID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::SlabString; break;
case API_RoofID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RoofString; break;
case API_MeshID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::MeshString; break;
case API_DimensionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::DimensionString; break;
case API_RadialDimensionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RadialDimensionString; break;
case API_LevelDimensionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::LevelDimensionString; break;
case API_AngleDimensionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::AngleDimensionString; break;
case API_TextID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::TextString; break;
case API_LabelID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::LabelString; break;
case API_ZoneID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ZoneString; break;
case API_HatchID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::HatchString; break;
case API_LineID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::LineString; break;
case API_PolyLineID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::PolyLineString; break;
case API_ArcID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ArcString; break;
case API_CircleID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CircleString; break;
case API_SplineID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::SplineString; break;
case API_HotspotID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::HotspotString; break;
case API_CutPlaneID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CutPlaneString; break;
case API_CameraID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CameraString; break;
case API_CamSetID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CamSetString; break;
case API_GroupID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::GroupString; break;
case API_SectElemID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::SectElemString; break;
case API_DrawingID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::DrawingString; break;
case API_PictureID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::PictureString; break;
case API_DetailID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::DetailString; break;
case API_ElevationID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ElevationString; break;
case API_InteriorElevationID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::InteriorElevationString; break;
case API_WorksheetID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::WorksheetString; break;
case API_HotlinkID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::HotlinkString; break;
case API_CurtainWallID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallString; break;
case API_CurtainWallSegmentID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallSegmentString; break;
case API_CurtainWallFrameID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallFrameString; break;
case API_CurtainWallPanelID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallPanelString; break;
case API_CurtainWallJunctionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallJunctionString; break;
case API_CurtainWallAccessoryID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::CurtainWallAccessoryString; break;
case API_ShellID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ShellString; break;
case API_SkylightID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::SkylightString; break;
case API_MorphID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::MorphString; break;
case API_ChangeMarkerID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ChangeMarkerString; break;
case API_StairID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::StairString; break;
case API_RiserID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RiserString; break;
case API_TreadID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::TreadString; break;
case API_StairStructureID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::StairStructureString; break;
case API_RailingID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingString; break;
case API_RailingToprailID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingToprailString; break;
case API_RailingHandrailID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingHandrailString; break;
case API_RailingRailID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingRailString; break;
case API_RailingPostID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingPostString; break;
case API_RailingInnerPostID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingInnerPostString; break;
case API_RailingBalusterID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingBalusterString; break;
case API_RailingPanelID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingPanelString; break;
case API_RailingSegmentID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingSegmentString; break;
case API_RailingNodeID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingNodeString; break;
case API_RailingBalusterSetID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingBalusterSetString; break;
case API_RailingPatternID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingPatternString; break;
case API_RailingToprailEndID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingToprailEndString; break;
case API_RailingHandrailEndID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingHandrailEndString; break;
case API_RailingRailEndID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingRailEndString; break;
case API_RailingToprailConnectionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingToprailConnectionString; break;
case API_RailingHandrailConnectionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingHandrailConnectionString; break;
case API_RailingRailConnectionID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingRailConnectionString; break;
case API_RailingEndFinishID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::RailingEndFinishString; break;
case API_AnalyticalSupportID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::AnalyticalSupportString; break;
case API_AnalyticalLinkID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::AnalyticalLinkString; break;
case API_BeamSegmentID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::BeamSegmentString; break;
case API_ColumnSegmentID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::ColumnSegmentString; break;
case API_OpeningID: elementTypeStringItems = ResourceStrings::ElementTypeStringItems::OpeningString; break;
default:
{
return Error;
}
}
typeName = GetElementTypeStringFromResource (elementTypeStringItems);

return typeName.IsEmpty () ? Error : NoError;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions ConnectorArchicad/AddOn/Sources/AddOn/Utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace Utility {


// Element Type
API_ElemTypeID GetElementType (const API_Elem_Head& header);
API_ElemTypeID GetElementType (const API_Guid& guid);
GS::ErrCode GetTypeNameFromElementType(const API_Elem_Head& header, GS::UniString& typeName);
GS::ErrCode GetTypeNameFromElementType (const API_Elem_Head& header, GS::UniString& typeName);
void SetElementType (API_Elem_Head& header, const API_ElemTypeID& elementType);

bool ElementExists (const API_Guid& guid);
Expand Down
77 changes: 77 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOnResources/RINT/AddOn.grc
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,80 @@
'STR#' ID_DEFAULT_STORY_FORMAT "Default story name format" {
/* [ 1] */ "%d. Story"
}

'STR#' ID_ELEMENT_TYPE_STRINGS "Element Type Strings" {
/* [ 1] */ "Wall"
/* [ 2] */ "Column"
/* [ 3] */ "Beam"
/* [ 4] */ "Window"
/* [ 5] */ "Door"
/* [ 6] */ "Object"
/* [ 7] */ "Lamp"
/* [ 8] */ "Slab"
/* [ 9] */ "Roof"
/* [ 10] */ "Mesh"
/* [ 11] */ "Dimension"
/* [ 12] */ "Radial Dimension"
/* [ 13] */ "Level Dimension"
/* [ 14] */ "Angle Dimension"
/* [ 15] */ "Text"
/* [ 16] */ "Label"
/* [ 17] */ "Zone"
/* [ 18] */ "Hatch"
/* [ 19] */ "Line"
/* [ 10] */ "PolyLine"
/* [ 21] */ "Arc"
/* [ 22] */ "Circle"
/* [ 23] */ "Spline"
/* [ 24] */ "Hotspot"
/* [ 25] */ "CutPlane"
/* [ 26] */ "Camera"
/* [ 27] */ "CamSet"
/* [ 28] */ "Group"
/* [ 29] */ "SectElem"
/* [ 20] */ "Drawing"
/* [ 31] */ "Picture"
/* [ 32] */ "Detail"
/* [ 33] */ "Elevation"
/* [ 34] */ "Interior Elevation"
/* [ 35] */ "Worksheet"
/* [ 36] */ "Hotlink"
/* [ 37] */ "Curtain Wall"
/* [ 38] */ "Curtain Wall Segment"
/* [ 39] */ "Curtain Wall Frame"
/* [ 30] */ "Curtain Wall Panel"
/* [ 41] */ "Curtain Wall Junction"
/* [ 42] */ "Curtain Wall Accessory"
/* [ 43] */ "Shell"
/* [ 44] */ "Skylight"
/* [ 45] */ "Morph"
/* [ 46] */ "Change Marker"
/* [ 47] */ "Stair"
/* [ 48] */ "Riser"
/* [ 49] */ "Tread"
/* [ 40] */ "Stair Structure"
/* [ 51] */ "Railing"
/* [ 52] */ "Railing Toprail"
/* [ 53] */ "Railing Handrail"
/* [ 54] */ "Railing Rail"
/* [ 55] */ "Railing Post"
/* [ 56] */ "Railing Inner Post"
/* [ 57] */ "Railing Baluster"
/* [ 58] */ "Railing Panel"
/* [ 59] */ "Railing Segment"
/* [ 50] */ "Railing Node"
/* [ 61] */ "Railing Baluste rSet"
/* [ 62] */ "Railing Pattern"
/* [ 63] */ "Railing Toprail End"
/* [ 64] */ "Railing Handrail End"
/* [ 65] */ "Railing Rail End"
/* [ 66] */ "Railing Toprail Connection"
/* [ 67] */ "Railing Handrail Connection"
/* [ 68] */ "Railing Rail Connection"
/* [ 69] */ "Railing End Finish"
/* [ 70] */ "Analytical Support"
/* [ 71] */ "Analytical Link"
/* [ 72] */ "Beam Segment"
/* [ 73] */ "Column Segment"
/* [ 74] */ "Opening"
}

0 comments on commit b5bc2a6

Please sign in to comment.