Skip to content

Commit

Permalink
Merge branch 'dev' into update-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock authored Jan 13, 2025
2 parents a050409 + 029e10b commit bb50b59
Show file tree
Hide file tree
Showing 79 changed files with 241 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Autodesk.Revit.DB;

namespace Speckle.Connectors.Revit.HostApp;

public static class SupportedCategoriesUtils
{
/// <summary>
/// Filters out all categories besides Model categories. This utility should be used
/// to clean any elements we might want to send pre-conversion as well as in what categories
/// to display in our category filter.
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public static bool IsSupportedCategory(Category category)
{
return (
category.CategoryType == CategoryType.Model
// || category.CategoryType == CategoryType.AnalyticalModel
)
#if REVIT_2023_OR_GREATER
&& category.BuiltInCategory != BuiltInCategory.OST_AreaSchemes
&& category.BuiltInCategory != BuiltInCategory.OST_AreaSchemeLines
#else
&& category.Name != "OST_AreaSchemeLines"
&& category.Name != "OST_AreaSchemes"
#endif
&& category.IsVisibleInUI;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Speckle.Connectors.DUI.Exceptions;
using Speckle.Connectors.DUI.Models.Card.SendFilter;
using Speckle.Connectors.DUI.Utils;
using Speckle.Connectors.Revit.HostApp;
using Speckle.Converters.RevitShared.Helpers;

namespace Speckle.Connectors.RevitShared.Operations.Send.Filters;
Expand Down Expand Up @@ -69,7 +70,10 @@ private void GetCategories()

foreach (Category category in _doc.Settings.Categories)
{
categories.Add(new CategoryData(category.Name, category.Id.ToString()));
if (SupportedCategoriesUtils.IsSupportedCategory(category))
{
categories.Add(new CategoryData(category.Name, category.Id.ToString()));
}
}

AvailableCategories = categories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ private void GetViews()
.OfClass(typeof(View))
.Cast<View>()
.Where(v => !v.IsTemplate)
.Where(v => !v.IsAssemblyView)
.Where(v =>
v.ViewType
is ViewType.FloorPlan
or ViewType.Elevation
or ViewType.Rendering
or ViewType.Section
or ViewType.ThreeD
or ViewType.Detail
or ViewType.CeilingPlan
or ViewType.AreaPlan
)
.Select(v => v.ViewType.ToString() + " - " + v.Name.ToString())
.ToList();
AvailableViews = views;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,43 @@ CancellationToken cancellationToken
rootObject["units"] = converterSettings.Current.SpeckleUnits;

var revitElements = new List<Element>();

List<SendConversionResult> results = new(revitElements.Count);
// Convert ids to actual revit elements
foreach (var id in objects)
{
var el = converterSettings.Current.Document.GetElement(id);
if (el != null)
if (el == null)
{
continue;
}

if (el.Category == null)
{
revitElements.Add(el);
continue;
}

if (!SupportedCategoriesUtils.IsSupportedCategory(el.Category))
{
results.Add(
new(
Status.WARNING,
el.UniqueId,
el.Category.Name,
null,
new SpeckleException($"Category {el.Category.Name} is not supported.")
)
);
continue;
}

revitElements.Add(el);
}

if (revitElements.Count == 0)
{
throw new SpeckleSendFilterException("No objects were found. Please update your send filter!");
throw new SpeckleSendFilterException("No objects were found. Please update your publish filter!");
}

List<SendConversionResult> results = new(revitElements.Count);

// Unpack groups (& other complex data structures)
var atomicObjects = elementUnpacker.UnpackSelectionForConversion(revitElements).ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<Compile Include="$(MSBuildThisFileDirectory)HostApp\DocumentModelStorageSchema.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\Elements.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\RevitMaterialBaker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\SupportedCategoriesUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\HideWarningsFailuresPreprocessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\IdStorageSchema.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\IStorageSchema.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ or System.Security.SecurityException
public Uri ValidateDatabasePath(Uri originalGatabasePath)
{
var fGdbName = originalGatabasePath.Segments[^1];
var parentFolder = Path.GetDirectoryName(originalGatabasePath.AbsolutePath);
if (parentFolder == null)
{
// POC: customize the exception type
throw new ArgumentException($"Invalid path: {originalGatabasePath}");
}

// Uri.AbsolutePath will return escaped string (replacing spaces), we need them back via .UnescapeDataString
var parentFolder = Uri.UnescapeDataString(
Path.GetDirectoryName(originalGatabasePath.AbsolutePath)
?? throw new ArgumentException($"Invalid path: {originalGatabasePath}")
);
Uri databasePath = originalGatabasePath;
Item folderToAdd = ItemFactory.Instance.Create(parentFolder);

if (folderToAdd is null)
{
// ArcGIS API doesn't show it as nullable, but it is
Expand Down Expand Up @@ -133,7 +133,10 @@ public Uri ValidateDatabasePath(Uri originalGatabasePath)
public Uri AddDatabaseToProject(Uri databasePath)
{
// Add a folder connection to a project
var parentFolder = Path.GetDirectoryName(databasePath.AbsolutePath);
// Uri.AbsolutePath will return escaped string (replacing spaces), we need them back via .UnescapeDataString
var parentFolder = Uri.UnescapeDataString(
Path.GetDirectoryName(databasePath.AbsolutePath) ?? throw new ArgumentException($"Invalid path: {databasePath}")
);
var fGdbName = databasePath.Segments[^1];
Item folderToAdd = ItemFactory.Instance.Create(parentFolder);
Project.Current.AddItem(folderToAdd as IProjectItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Arc, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Circle, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Ellipse, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(DisplayableObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class FallbackToHostConverter : IToHostTopLevelConverter, ITypedConverter<DisplayableObject, ACG.Geometry>
{
private readonly ITypedConverter<List<SOG.Mesh>, ACG.Multipatch> _meshListConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class LineSingleToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Line, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Mesh, ACG.Multipatch>
{
private readonly ITypedConverter<List<SOG.Mesh>, ACG.Multipatch> _meshConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PointToHostConverter : IToHostTopLevelConverter
{
private readonly ITypedConverter<List<SOG.Point>, ACG.Multipoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PolycurveToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Polycurve, ACG.Polyline>
{
private readonly IRootToHostConverter _converter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.ArcGIS3.ToHost.TopLevel;

[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Polyline, ACG.Polyline>
{
private readonly ITypedConverter<SOG.Point, ACG.MapPoint> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Speckle.Converters.ArcGIS3.ToSpeckle.TopLevel;

[NameAndRankValue(nameof(AC.CoreObjectsBase), 0)]
[NameAndRankValue(typeof(AC.CoreObjectsBase), 0)]
public class CoreObjectsBaseToSpeckleTopLevelConverter : IToSpeckleTopLevelConverter
{
private readonly DisplayValueExtractor _displayValueExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class ArcToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Arc, ADB.Arc>
{
private readonly ITypedConverter<SOG.Arc, AG.CircularArc3d> _arcConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.Autocad2023.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Autocad.AutocadPolycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Autocad.AutocadPolycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class AutocadPolycurveToHostConverter : IToHostTopLevelConverter
{
private readonly ITypedConverter<SOG.Autocad.AutocadPolycurve, ADB.Polyline> _polylineConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class CircleToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Circle, ADB.Circle>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.AutocadShared.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Curve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class CurveToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Curve, ADB.Curve>
{
private readonly ITypedConverter<SOG.Curve, AG.NurbCurve3d> _curveConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Speckle.Converters.Rhino7.ToHost.TopLevel;

[NameAndRankValue(nameof(DataObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(DataObject), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DataObjectConverter : IToHostTopLevelConverter, ITypedConverter<DataObject, List<(ADB.Entity a, Base b)>>
{
private readonly ITypedConverter<SOG.Line, ADB.Line> _lineConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class EllipseToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Ellipse, ADB.Ellipse>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class LineToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Line, ADB.Line>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Speckle.Converters.Autocad.Geometry;

[NameAndRankValue(nameof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Mesh), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class MeshToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Mesh, ADB.PolyFaceMesh>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Point), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PointToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Point, ADB.DBPoint>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Speckle.Converters.AutocadShared.ToHost.Geometry;
/// If polycurve segments are planar and only of type <see cref="SOG.Line"/> and <see cref="SOG.Arc"/>, it can be represented as Polyline in Autocad.
/// Otherwise we convert it as spline (list of ADB.Entity) that switch cases according to each segment type.
/// </summary>
[NameAndRankValue(nameof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Polycurve), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PolycurveToHostConverter : IToHostTopLevelConverter
{
private readonly ITypedConverter<SOG.Polycurve, ADB.Polyline> _polylineConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToHost.Geometry;

[NameAndRankValue(nameof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Polyline), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class PolylineToHostConverter : IToHostTopLevelConverter, ITypedConverter<SOG.Polyline, ADB.Polyline3d>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToHost.Raw;

[NameAndRankValue(nameof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(SOG.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class ArcToHostRowConverter : ITypedConverter<SOG.Arc, AG.CircularArc3d>
{
private readonly ITypedConverter<SOG.Point, AG.Point3d> _pointConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(ADB.Arc), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBArcToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<ADB.Arc, SOG.Arc> _arcConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(ADB.Circle), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBCircleToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<ADB.Circle, SOG.Circle> _circleConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(ADB.Ellipse), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class DBEllipseToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<ADB.Ellipse, SOG.Ellipse> _ellipseConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Speckle.Converters.Autocad.ToSpeckle.Geometry;

[NameAndRankValue(nameof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
[NameAndRankValue(typeof(ADB.Line), NameAndRankValueAttribute.SPECKLE_DEFAULT_RANK)]
public class LineToSpeckleConverter : IToSpeckleTopLevelConverter
{
private readonly ITypedConverter<ADB.Line, SOG.Line> _lineConverter;
Expand Down
Loading

0 comments on commit bb50b59

Please sign in to comment.