Skip to content

Commit

Permalink
Merge pull request #361 from specklesystems/dimitrie/cnx-634-some-ele…
Browse files Browse the repository at this point in the history
…ments-are-received-as-generic-models-ignoring

Dimitrie/cnx 634 some elements are received as generic models ignoring
  • Loading branch information
didimitrie authored Nov 6, 2024
2 parents d5f1f76 + ba4cfca commit 5f4eebe
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.Common.Registration;
using Speckle.Converters.RevitShared.Extensions;
using Speckle.Converters.RevitShared.Settings;
using Speckle.Converters.RevitShared.ToSpeckle;
using Speckle.Sdk;
Expand Down Expand Up @@ -58,6 +59,7 @@ public Base Convert(object target)
if (target is not DB.DirectShape)
{
result["category"] = element.Category?.Name;
result["builtinCategory"] = element.Category?.GetBuiltInCategory().ToString();
}

try
Expand Down
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 @@ -29,11 +29,11 @@ public LocalToGlobalToDirectShapeConverter(
public DB.DirectShape Convert((Base atomicObject, List<Matrix4x4> matrix) target)
{
// 1- set ds category
var category = target.atomicObject["category"] as string;
var category = target.atomicObject["builtinCategory"] as string;
var dsCategory = DB.BuiltInCategory.OST_GenericModel;
if (category is not null)
{
var res = Enum.TryParse($"OST_{category}", out DB.BuiltInCategory cat);
var res = Enum.TryParse(category, out DB.BuiltInCategory cat);
if (res)
{
var c = DB.Category.GetCategory(_converterSettings.Current.Document, cat);
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 5f4eebe

Please sign in to comment.