diff --git a/Revit_Core_Engine/Objects/Active2dViewVisibilityContext.cs b/Revit_Core_Engine/Objects/Active2dViewVisibilityContext.cs index 5ddab5a87..2b532815c 100644 --- a/Revit_Core_Engine/Objects/Active2dViewVisibilityContext.cs +++ b/Revit_Core_Engine/Objects/Active2dViewVisibilityContext.cs @@ -23,6 +23,7 @@ using Autodesk.Revit.DB; using System.ComponentModel; +#if (!REVIT2018 && !REVIT2019) namespace BH.Revit.Engine.Core { [Description("Class used to extract elements visible in the active view of the host document if that view is of 2d type. See " + nameof(Query.ElementIdsByVisibleInActiveView) + " for usage example.")] @@ -105,3 +106,4 @@ public void OnText(TextNode node) /***************************************************/ } } +#endif \ No newline at end of file diff --git a/Revit_Core_Engine/Query/ElementIds/ElementIdsByVisibleInActiveView.cs b/Revit_Core_Engine/Query/ElementIds/ElementIdsByVisibleInActiveView.cs index 0df9d5726..0496930ff 100644 --- a/Revit_Core_Engine/Query/ElementIds/ElementIdsByVisibleInActiveView.cs +++ b/Revit_Core_Engine/Query/ElementIds/ElementIdsByVisibleInActiveView.cs @@ -22,7 +22,6 @@ using Autodesk.Revit.DB; using BH.oM.Base.Attributes; -using System; using System.Collections.Generic; using System.ComponentModel; @@ -49,13 +48,23 @@ public static IEnumerable ElementIdsByVisibleInActiveView(this Docume if (hostDocument.ActiveView is View3D) context = new ActiveViewVisibilityContext(hostDocument, document); else + { +#if (REVIT2018 || REVIT2019) + BH.Engine.Base.Compute.RecordError($"Querying visible elements from the active view failed because only 3d views are supported in Revit 2019 or older. In later versions also 2d views can be queried."); + return null; +#else context = new Active2dViewVisibilityContext(hostDocument, document); +#endif + } CustomExporter exporter = new CustomExporter(hostDocument, context); exporter.IncludeGeometricObjects = false; - exporter.Export2DIncludingAnnotationObjects = true; exporter.ShouldStopOnError = false; +#if (!REVIT2018 && !REVIT2019) + exporter.Export2DIncludingAnnotationObjects = true; +#endif + try { exporter.Export(new List { hostDocument.ActiveView.Id }); @@ -79,7 +88,5 @@ public static IEnumerable ElementIdsByVisibleInActiveView(this Docume } /***************************************************/ - } - - + } }