@@ -19,24 +19,29 @@ GS::Optional<GS::UniString> CreateColumnsCommand::GetInputParametersSchema () co
1919 "properties": {
2020 "%s": {
2121 "type": "array",
22- "description": "The 2D coordinates of the new columns.",
22+ "description": "The 3D coordinates of the new columns' origos .",
2323 "items": {
2424 "type": "object",
25- "description" : "Position of a 2D point .",
25+ "description" : "3D coordinate .",
2626 "properties" : {
2727 "x": {
2828 "type": "number",
29- "description" : "X value of the point ."
29+ "description" : "X value of the coordinate ."
3030 },
3131 "y" : {
3232 "type": "number",
33- "description" : "Y value of the point."
33+ "description" : "Y value of the coordinate."
34+ },
35+ "z" : {
36+ "type": "number",
37+ "description" : "Z value of the coordinate."
3438 }
3539 },
3640 "additionalProperties": false,
3741 "required" : [
3842 "x",
39- "y"
43+ "y",
44+ "z"
4045 ]
4146 }
4247 }
@@ -51,11 +56,12 @@ CoordinatesParameterField);
5156}
5257
5358
54- static API_Coord GetCoordinateFromObjectState (const GS::ObjectState& objectState)
59+ static API_Coord3D GetCoordinateFromObjectState (const GS::ObjectState& objectState)
5560{
56- API_Coord coordinate = {};
61+ API_Coord3D coordinate = {};
5762 objectState.Get (" x" , coordinate.x );
5863 objectState.Get (" y" , coordinate.y );
64+ objectState.Get (" z" , coordinate.z );
5965 return coordinate;
6066}
6167
@@ -65,23 +71,27 @@ GS::ObjectState CreateColumnsCommand::Execute (const GS::ObjectState& parameters
6571 GS::Array<GS::ObjectState> coordinates;
6672 parameters.Get (CoordinatesParameterField, coordinates);
6773
68- API_Coord apiCoordinate = {};
74+ API_Coord3D apiCoordinate = {};
6975 const APIErrCodes err = (APIErrCodes) ACAPI_CallUndoableCommand (" Create Columns" , [&] () -> GSErrCode {
7076 API_Element element = {};
7177 API_ElementMemo memo = {};
7278 const GS::OnExit guard ([&memo] () { ACAPI_DisposeElemMemoHdls (&memo); });
7379
74- #ifdef ServerMainVers_2600
75- element.header .type = API_ElemType ( API_ColumnID); // AC26
76- #else
77- element.header .typeID = API_ColumnID; // AC25
78- #endif
80+ #ifdef ServerMainVers_2600
81+ element.header .type = API_ColumnID;
82+ #else
83+ element.header .typeID = API_ColumnID;
84+ #endif
7985 APIErrCodes err = (APIErrCodes) ACAPI_Element_GetDefaults (&element, &memo);
8086
87+ const GS::Array<GS::Pair<short , double >> storyLevels = Utilities::GetStoryLevels ();
88+
8189 for (const GS::ObjectState& coordinate : coordinates) {
8290 apiCoordinate = GetCoordinateFromObjectState (coordinate);
8391
84- element.column .origoPos = apiCoordinate;
92+ element.header .floorInd = Utilities::GetFloorIndexAndOffset (apiCoordinate.z , storyLevels, element.column .bottomOffset );
93+ element.column .origoPos .x = apiCoordinate.x ;
94+ element.column .origoPos .y = apiCoordinate.y ;
8595 err = (APIErrCodes) ACAPI_Element_Create (&element, &memo);
8696
8797 if (err != NoError) {
@@ -93,7 +103,7 @@ GS::ObjectState CreateColumnsCommand::Execute (const GS::ObjectState& parameters
93103 });
94104
95105 if (err != NoError) {
96- const GS::UniString errorMsg = GS::UniString::Printf (" Failed to create column to coordinate: {%.2f, %.2f}!" , apiCoordinate.x , apiCoordinate.y );
106+ const GS::UniString errorMsg = GS::UniString::Printf (" Failed to create column to coordinate: {%.2f, %.2f, %.2f }!" , apiCoordinate.x , apiCoordinate.y , apiCoordinate. z );
97107 return CreateErrorResponse (err, errorMsg);
98108 }
99109
0 commit comments