diff --git a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs index 36b229fe6b..1786febd39 100644 --- a/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs +++ b/DUI3-DX/Converters/Revit/Speckle.Converters.RevitShared/Raw/ColumnConversionToSpeckle.cs @@ -43,26 +43,48 @@ public RevitColumn Convert(DB.FamilyInstance target) RevitColumn speckleColumn = new() { family = symbol.FamilyName, type = target.Document.GetElement(target.GetTypeId()).Name }; - Level level = _parameterValueExtractor.GetValueAsDocumentObject( - target, - BuiltInParameter.FAMILY_BASE_LEVEL_PARAM - ); - speckleColumn.level = _levelConverter.Convert(level); - - Level topLevel = _parameterValueExtractor.GetValueAsDocumentObject( - target, - BuiltInParameter.FAMILY_TOP_LEVEL_PARAM - ); - - speckleColumn.topLevel = _levelConverter.Convert(topLevel); - speckleColumn.baseOffset = _parameterValueExtractor.GetValueAsDouble( - target, - DB.BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM - ); - speckleColumn.topOffset = _parameterValueExtractor.GetValueAsDouble( - target, - DB.BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM - ); + if ( + _parameterValueExtractor.TryGetValueAsDocumentObject( + target, + BuiltInParameter.FAMILY_BASE_LEVEL_PARAM, + out var level + ) + ) + { + speckleColumn.level = _levelConverter.Convert(level.NotNull()); + } + if ( + _parameterValueExtractor.TryGetValueAsDocumentObject( + target, + BuiltInParameter.FAMILY_TOP_LEVEL_PARAM, + out var topLevel + ) + ) + { + speckleColumn.topLevel = _levelConverter.Convert(topLevel.NotNull()); + } + + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM, + out var baseOffset + ) + ) + { + speckleColumn.baseOffset = baseOffset.NotNull(); + } + + if ( + _parameterValueExtractor.TryGetValueAsDouble( + target, + BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM, + out var topOffset + ) + ) + { + speckleColumn.topOffset = topOffset.NotNull(); + } speckleColumn.facingFlipped = target.FacingFlipped; speckleColumn.handFlipped = target.HandFlipped; @@ -74,7 +96,7 @@ public RevitColumn Convert(DB.FamilyInstance target) } speckleColumn.baseLine = - GetBaseCurve(target, speckleColumn.topLevel.elevation, speckleColumn.topOffset) + GetBaseCurve(target, speckleColumn.topLevel?.elevation ?? -1, speckleColumn.topOffset) ?? throw new SpeckleConversionException("Unable to find a valid baseCurve for column"); speckleColumn.displayValue = _displayValueExtractor.GetDisplayValue(target);