Skip to content

Commit

Permalink
Back to old except for FootPrintRoof
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jun 14, 2024
1 parent c2ef5f9 commit ce610fe
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,28 @@ public bool TryGetValueAsElementId(
return GetValueGeneric(parameter, RevitStorageType.ElementId, (p) => p.AsElementId());
}

public IRevitLevel? GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter)
public IRevitLevel GetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter)
{
if (!TryGetValueAsElementId(element, builtInParameter, out var elementId))
{
return null;
throw new SpeckleConversionException();
}

var paramElement = element.Document.GetElement(elementId);
return (paramElement?.ToLevel()).NotNull();
}

public bool TryGetValueAsRevitLevel(IRevitElement element, RevitBuiltInParameter builtInParameter, [NotNullWhen(true)] out IRevitLevel? revitLevel)
{
if (!TryGetValueAsElementId(element, builtInParameter, out var elementId))
{
revitLevel = null;
return false;
}

var paramElement = element.Document.GetElement(elementId);
return paramElement?.ToLevel();
revitLevel = paramElement?.ToLevel();
return revitLevel is not null;
}

private TResult? GetValueGeneric<TResult>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Objects;
using Objects;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.RevitShared.Helpers;
Expand Down Expand Up @@ -58,10 +58,7 @@ public SOBR.RevitBeam Convert(IRevitFamilyInstance target)
target,
RevitBuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM
);
if (level is not null)
{
speckleBeam.level = _levelConverter.Convert(level);
}
speckleBeam.level = _levelConverter.Convert(level);

speckleBeam.displayValue = _displayValueExtractor.GetDisplayValue(target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public SOBR.RevitColumn Convert(IRevitFamilyInstance target)
new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).NotNull().Name };

var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
speckleColumn.level = _levelConverter.Convert(level.NotNull());
speckleColumn.level = _levelConverter.Convert(level);

var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.FAMILY_TOP_LEVEL_PARAM);

speckleColumn.topLevel = _levelConverter.Convert(topLevel.NotNull());
speckleColumn.topLevel = _levelConverter.Convert(topLevel);
speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble(
target,
RevitBuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Objects;
using Objects;
using Objects.BuiltElements.Revit;
using Objects.Geometry;
using Speckle.Converters.Common;
Expand Down Expand Up @@ -60,10 +60,7 @@ public override RevitCeiling Convert(IRevitCeiling target)
// but it is never being set. We should be setting it

var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM);
if (level is not null)
{
speckleCeiling.level = _levelConverter.Convert(level);
}
speckleCeiling.level = _levelConverter.Convert(level);

_parameterObjectAssigner.AssignParametersToBase(target, speckleCeiling);
speckleCeiling.displayValue = _displayValueExtractor.GetDisplayValue(target);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Objects.BuiltElements.Revit.RevitRoof;
using Objects.BuiltElements.Revit.RevitRoof;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.RevitShared.Extensions;
Expand Down Expand Up @@ -57,11 +57,7 @@ public override RevitExtrusionRoof Convert(IRevitExtrusionRoof target)
target,
RevitBuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM
);
if (level is not null)
{
speckleExtrusionRoof.level = _levelConverter.Convert(level);
}

speckleExtrusionRoof.level = _levelConverter.Convert(level);
speckleExtrusionRoof.outline = _modelCurveArrayConverter.Convert(target.GetProfile());

var elementType = target.Document.GetElement(target.GetTypeId()).NotNull().ToType().NotNull();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Objects;
using Objects;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.RevitShared.Helpers;
Expand Down Expand Up @@ -63,11 +63,7 @@ public override SOBR.RevitFloor Convert(IRevitFloor target)
}

var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.LEVEL_PARAM);
if (level is not null)
{
speckleFloor.level = _levelConverter.Convert(level);
}

speckleFloor.level = _levelConverter.Convert(level.NotNull());
speckleFloor.structural =
_parameterValueExtractor.GetValueAsBool(target, RevitBuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL) ?? false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target)
var baseLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_BASE_LEVEL_PARAM);

// We don't currently validate the success of this TryGet, it is assumed some Roofs don't have a top-level.
var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM);
IRevitLevel? topLevel;
_parameterValueExtractor.TryGetValueAsRevitLevel(target, RevitBuiltInParameter.ROOF_UPTO_LEVEL_PARAM, out topLevel);

//POC: CNX-9403 can be null if the sides have different slopes.
//We currently don't validate the success or failure of this TryGet as it's not necessary, but will be once we start the above ticket.
Expand All @@ -53,7 +54,7 @@ public override RevitFootprintRoof Convert(IRevitFootPrintRoof target)
RevitFootprintRoof speckleFootprintRoof =
new()
{
level = _levelConverter.Convert(baseLevel.NotNull()),
level = _levelConverter.Convert(baseLevel),
cutOffLevel = topLevel is not null ? _levelConverter.Convert(topLevel) : null,
slope = slope
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Speckle.Converters.Common.Objects;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.Common;
using Objects;
using Speckle.Converters.RevitShared.Helpers;
Expand Down Expand Up @@ -74,16 +74,10 @@ private void AssignSpecificParameters(IRevitWall target, RevitWall speckleWall)
speckleWall.baseLine = _curveConverter.Convert(locationCurve.Curve);

var level = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT);
if (level is not null)
{
speckleWall.level = _levelConverter.Convert(level);
}
speckleWall.level = _levelConverter.Convert(level);

var topLevel = _parameterValueExtractor.GetValueAsRevitLevel(target, RevitBuiltInParameter.WALL_BASE_CONSTRAINT);
if (topLevel is not null)
{
speckleWall.topLevel = _levelConverter.Convert(topLevel);
}
speckleWall.topLevel = _levelConverter.Convert(topLevel);

// POC : what to do if these parameters are unset (instead of assigning default)
_ = _parameterValueExtractor.TryGetValueAsDouble(
Expand Down

0 comments on commit ce610fe

Please sign in to comment.