Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimitrie/cnx 634 some elements are received as generic models ignoring #361

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading