Skip to content

Commit

Permalink
New command: GetDetailsOfElements (#103)
Browse files Browse the repository at this point in the history
* New command: GetDetailsOfElements

* "type" should return non-localized name

* Do not use ElemID_To_Name because it returns non-localized name, use GetElementTypeNonLocalizedName instead
  • Loading branch information
tlorantfy authored Aug 20, 2024
1 parent d6f8b19 commit 87ad399
Show file tree
Hide file tree
Showing 11 changed files with 599 additions and 53 deletions.
24 changes: 24 additions & 0 deletions archicad-addon/Examples/get_details_of_selected_elements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
import aclib

commandName = 'GetSelectedElements'
commandParameters = {}

print ('Command: {commandName}'.format (commandName = commandName))
print ('Parameters:')
print (json.dumps (commandParameters, indent = 4))

response = aclib.RunTapirCommand (commandName, commandParameters)
print ('Response:')
print (json.dumps (response, indent = 4))

commandName = 'GetDetailsOfElements'
commandParameters = response

print ('Command: {commandName}'.format (commandName = commandName))
print ('Parameters:')
print (json.dumps (commandParameters, indent = 4))

response = aclib.RunTapirCommand (commandName, commandParameters)
print ('Response:')
print (json.dumps (response, indent = 4))
1 change: 1 addition & 0 deletions archicad-addon/Sources/AddOnMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ GSErrCode Initialize (void)
err |= ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler (GS::NewOwned<GetHotlinksCommand> ());
err |= ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler (GS::NewOwned<PublishPublisherSetCommand> ());

err |= ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler (GS::NewOwned<GetDetailsOfElementsCommand> ());
err |= ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler (GS::NewOwned<GetSelectedElementsCommand> ());
err |= ACAPI_AddOnAddOnCommunication_InstallAddOnCommandHandler (GS::NewOwned<GetSubelementsOfHierarchicalElementsCommand> ());
#ifdef ServerMainVers_2600
Expand Down
84 changes: 84 additions & 0 deletions archicad-addon/Sources/CommandBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ API_Coord Get2DCoordinateFromObjectState (const GS::ObjectState& objectState)
return coordinate;
}

GS::ObjectState Create2DCoordinateObjectState (const API_Coord& c)
{
return GS::ObjectState ("x", c.x, "y", c.y);
}

API_Coord3D Get3DCoordinateFromObjectState (const GS::ObjectState& objectState)
{
API_Coord3D coordinate = {};
Expand Down Expand Up @@ -129,4 +134,83 @@ GS::Pair<short, double> GetFloorIndexAndOffset (const double zPos, const Stories
}

return { storyPtr->index, zPos - storyPtr->level };
}

GS::UniString GetElementTypeNonLocalizedName (API_ElemTypeID typeID)
{
switch (typeID) {
case API_WallID: return "Wall";
case API_ColumnID: return "Column";
case API_BeamID: return "Beam";
case API_WindowID: return "Window";
case API_DoorID: return "Door";
case API_ObjectID: return "Object";
case API_LampID: return "Lamp";
case API_SlabID: return "Slab";
case API_RoofID: return "Roof";
case API_MeshID: return "Mesh";
case API_DimensionID: return "Dimension";
case API_RadialDimensionID: return "RadialDimension";
case API_LevelDimensionID: return "LevelDimension";
case API_AngleDimensionID: return "AngleDimension";
case API_TextID: return "Text";
case API_LabelID: return "Label";
case API_ZoneID: return "Zone";
case API_HatchID: return "Hatch";
case API_LineID: return "Line";
case API_PolyLineID: return "PolyLine";
case API_ArcID: return "Arc";
case API_CircleID: return "Circle";
case API_SplineID: return "Spline";
case API_HotspotID: return "Hotspot";
case API_CutPlaneID: return "CutPlane";
case API_CameraID: return "Camera";
case API_CamSetID: return "CamSet";
case API_GroupID: return "Group";
case API_SectElemID: return "SectElem";
case API_DrawingID: return "Drawing";
case API_PictureID: return "Picture";
case API_DetailID: return "Detail";
case API_ElevationID: return "Elevation";
case API_InteriorElevationID: return "InteriorElevation";
case API_WorksheetID: return "Worksheet";
case API_HotlinkID: return "Hotlink";
case API_CurtainWallID: return "CurtainWall";
case API_CurtainWallSegmentID: return "CurtainWallSegment";
case API_CurtainWallFrameID: return "CurtainWallFrame";
case API_CurtainWallPanelID: return "CurtainWallPanel";
case API_CurtainWallJunctionID: return "CurtainWallJunction";
case API_CurtainWallAccessoryID: return "CurtainWallAccessory";
case API_ShellID: return "Shell";
case API_SkylightID: return "Skylight";
case API_MorphID: return "Morph";
case API_ChangeMarkerID: return "ChangeMarker";
case API_StairID: return "Stair";
case API_RiserID: return "Riser";
case API_TreadID: return "Tread";
case API_StairStructureID: return "StairStructure";
case API_RailingID: return "Railing";
case API_RailingToprailID: return "RailingToprail";
case API_RailingHandrailID: return "RailingHandrail";
case API_RailingRailID: return "RailingRail";
case API_RailingPostID: return "RailingPost";
case API_RailingInnerPostID: return "RailingInnerPost";
case API_RailingBalusterID: return "RailingBaluster";
case API_RailingPanelID: return "RailingPanel";
case API_RailingSegmentID: return "RailingSegment";
case API_RailingNodeID: return "RailingNode";
case API_RailingBalusterSetID: return "RailingBalusterSet";
case API_RailingPatternID: return "RailingPattern";
case API_RailingToprailEndID: return "RailingToprailEnd";
case API_RailingHandrailEndID: return "RailingHandrailEnd";
case API_RailingRailEndID: return "RailingRailEnd";
case API_RailingToprailConnectionID: return "RailingToprailConnection";
case API_RailingHandrailConnectionID: return "RailingHandrailConnection";
case API_RailingRailConnectionID: return "RailingRailConnection";
case API_RailingEndFinishID: return "RailingEndFinish";
case API_BeamSegmentID: return "BeamSegment";
case API_ColumnSegmentID: return "ColumnSegment";
case API_OpeningID: return "Opening";
default: return "Unknown";
}
}
4 changes: 3 additions & 1 deletion archicad-addon/Sources/CommandBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GS::ObjectState CreateSuccessfulExecutionResult ();

API_Guid GetGuidFromObjectState (const GS::ObjectState& os);
API_Coord Get2DCoordinateFromObjectState (const GS::ObjectState& objectState);
GS::ObjectState Create2DCoordinateObjectState (const API_Coord& c);
API_Coord3D Get3DCoordinateFromObjectState (const GS::ObjectState& objectState);

struct Story {
Expand All @@ -50,4 +51,5 @@ struct Story {
using Stories = GS::Array<Story>;

Stories GetStories ();
GS::Pair<short, double> GetFloorIndexAndOffset (const double zPos, const Stories& stories);
GS::Pair<short, double> GetFloorIndexAndOffset (const double zPos, const Stories& stories);
GS::UniString GetElementTypeNonLocalizedName (API_ElemTypeID typeID);
Loading

0 comments on commit 87ad399

Please sign in to comment.