Skip to content

Commit

Permalink
feat: adds top level converter for railings
Browse files Browse the repository at this point in the history
and fixes a different bug
  • Loading branch information
didimitrie committed Nov 6, 2024
1 parent 8a0c9d0 commit f6e4fcd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\FootPrintRoofToSpeckleTopLevelConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\HostedElementConversionToSpeckle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\ModelCurveToSpeckleTopLevelConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\RailingTopLevelConverterToSpeckle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\RoofBaseToSpeckleTopLevelTopLevelConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\RoomTopLevelConverterToSpeckle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\TopographyTopLevelConverterToSpeckle.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override RevitElement Convert(DB.Element target)
? symbol.FamilyName
: "no family";
string category = target.Category?.Name ?? "no category";
List<Speckle.Objects.Geometry.Mesh> displayValue = _displayValueExtractor.GetDisplayValue(target);
List<Objects.Geometry.Mesh> displayValue = _displayValueExtractor.GetDisplayValue(target);

RevitElement speckleElement =
new()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Speckle.Converters.Common;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Converters.RevitShared.Settings;
using Speckle.Converters.RevitShared.ToSpeckle;

namespace Speckle.Converters.Revit2023.ToSpeckle.TopLevel;

[NameAndRankValue(nameof(DBA.Railing), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class RailingTopLevelConverterToSpeckle : BaseTopLevelConverterToSpeckle<DBA.Railing, SOBR.RevitElement>
{
private readonly DisplayValueExtractor _displayValueExtractor;
private readonly IConverterSettingsStore<RevitConversionSettings> _converterSettings;

public RailingTopLevelConverterToSpeckle(
DisplayValueExtractor displayValueExtractor,
IConverterSettingsStore<RevitConversionSettings> converterSettings
)
{
_displayValueExtractor = displayValueExtractor;
_converterSettings = converterSettings;
}

public override SOBR.RevitElement Convert(DBA.Railing target)
{
string family = target.Document.GetElement(target.GetTypeId()) is DB.FamilySymbol symbol
? symbol.FamilyName
: "no family";
string category = target.Category?.Name ?? "no category";
var displayValue = _displayValueExtractor.GetDisplayValue(target);

var topRail = _converterSettings.Current.Document.GetElement(target.TopRail);
var topRailDisplayValue = _displayValueExtractor.GetDisplayValue(topRail);

displayValue.AddRange(topRailDisplayValue);

SOBR.RevitElement speckleElement =
new()
{
type = target.Name,
category = category,
family = family,
displayValue = displayValue
};

speckleElement["units"] = _converterSettings.Current.SpeckleUnits;

return speckleElement;
}
}

0 comments on commit f6e4fcd

Please sign in to comment.