From 508b1838f3ded9c3a3760ba5b425d00409069465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20L=2E=20Kiss?= <50739844+jozseflkiss@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:35:13 +0200 Subject: [PATCH] fix(Revit): Inconsistent room area calculations (#2936) * Inconsistent room area calculations * cosmetic * cosmetic 2 --- .../AddOn/Sources/AddOn/Commands/GetZoneData.cpp | 2 +- .../Partial Classes/ConvertLevel.cs | 10 +++++----- .../Partial Classes/ConvertRoom.cs | 7 +++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ConnectorArchicad/AddOn/Sources/AddOn/Commands/GetZoneData.cpp b/ConnectorArchicad/AddOn/Sources/AddOn/Commands/GetZoneData.cpp index 99a6d4ea18..1f1f1fe6c3 100644 --- a/ConnectorArchicad/AddOn/Sources/AddOn/Commands/GetZoneData.cpp +++ b/ConnectorArchicad/AddOn/Sources/AddOn/Commands/GetZoneData.cpp @@ -59,7 +59,7 @@ GS::ErrCode GetZoneData::SerializeElementType (const API_Element& element, os.Add (ElementBase::Level, Objects::Level (story)); // The base point of the room - double level = Utility::GetStoryLevel (element.zone.head.floorInd) + element.zone.roomBaseLev; + double level = Utility::GetStoryLevel (element.zone.head.floorInd) + element.zone.roomBaseLev + element.zone.roomFlThick; { Geometry::Polygon2DData polygon; Utility::ConstructPoly2DDataFromElementMemo (memo, polygon); diff --git a/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertLevel.cs b/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertLevel.cs index 8da51c3ca6..75572933f2 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertLevel.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertLevel.cs @@ -34,19 +34,19 @@ public DB.Level GetExistingLevelByClosestElevation(IEnumerable docLeve public DB.Level ConvertLevelToRevit(XYZ point, out ApplicationObject.State state, out double elevationOffset) { var elevation = ElevationFromPoint(point); - return ConvertLevelToRevit(ObjectsLevelFromElevation(elevation), out state, out elevationOffset); + return ConvertLevelToRevit(ObjectsLevelFromElevation(elevation), false, out state, out elevationOffset); } public DB.Level ConvertLevelToRevit(Curve curve, out ApplicationObject.State state, out double elevationOffset) { var elevation = ElevationFromCurve(curve); - return ConvertLevelToRevit(ObjectsLevelFromElevation(elevation), out state, out elevationOffset); + return ConvertLevelToRevit(ObjectsLevelFromElevation(elevation), false, out state, out elevationOffset); } public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, out ApplicationObject.State state) { double elevationOffset = 0.0; - return ConvertLevelToRevit(speckleLevel, out state, out elevationOffset); + return ConvertLevelToRevit(speckleLevel, true, out state, out elevationOffset); } /// @@ -59,7 +59,7 @@ public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, out Applic /// /// /// - public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, out ApplicationObject.State state, out double elevationOffset) + public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, bool exactElevation, out ApplicationObject.State state, out double elevationOffset) { state = ApplicationObject.State.Unknown; elevationOffset = 0.0; @@ -93,7 +93,7 @@ public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, out Applic state = ApplicationObject.State.Updated; } //match by elevation - else if (elevationMatch && (GetExistingLevelByClosestElevation(docLevels, speckleLevelElevation, out elevationOffset) is DB.Level existingLevelWithClosestElevation)) + else if (!exactElevation && elevationMatch && (GetExistingLevelByClosestElevation(docLevels, speckleLevelElevation, out elevationOffset) is DB.Level existingLevelWithClosestElevation)) { revitLevel = existingLevelWithClosestElevation; state = ApplicationObject.State.Skipped; // state should be eliminated diff --git a/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertRoom.cs b/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertRoom.cs index 0fbd19f803..d2e3e4d43b 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertRoom.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitShared/Partial Classes/ConvertRoom.cs @@ -25,6 +25,13 @@ public ApplicationObject RoomToNative(Room speckleRoom) if (revitRoom == null) { var basePoint = PointToNative(speckleRoom.basePoint); + + // set computation level of Level based on the bottom elevation of the Room (Rooms can have offset elevation from Levels) + // it is not guaranteed that the final computation level will fit for all the Rooms, however not generating extra levels is preferred + if (level.get_Parameter(BuiltInParameter.LEVEL_ROOM_COMPUTATION_HEIGHT).AsDouble() < basePoint.Z) { + TrySetParam(level, BuiltInParameter.LEVEL_ROOM_COMPUTATION_HEIGHT, basePoint.Z); + } + revitRoom = Doc.Create.NewRoom(level, new UV(basePoint.X, basePoint.Y)); isUpdate = false; }