Skip to content

Commit

Permalink
fix(Revit): Inconsistent room area calculations (#2936)
Browse files Browse the repository at this point in the history
* Inconsistent room area calculations

* cosmetic

* cosmetic 2
  • Loading branch information
jozseflkiss authored Sep 20, 2023
1 parent 736d137 commit 508b183
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public DB.Level GetExistingLevelByClosestElevation(IEnumerable<DB.Level> 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);
}

/// <summary>
Expand All @@ -59,7 +59,7 @@ public DB.Level ConvertLevelToRevit(BuiltElements.Level speckleLevel, out Applic
/// </summary>
/// <param name="speckleLevel"></param>
/// <returns></returns>
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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 508b183

Please sign in to comment.