Skip to content

Commit

Permalink
context2d culled from Revit 2019 and older
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelbaran committed Oct 10, 2022
1 parent 621a6d5 commit be9d97d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Revit_Core_Engine/Objects/Active2dViewVisibilityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -105,3 +106,4 @@ public void OnText(TextNode node)
/***************************************************/
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

using Autodesk.Revit.DB;
using BH.oM.Base.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;

Expand All @@ -49,13 +48,23 @@ public static IEnumerable<ElementId> 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<ElementId> { hostDocument.ActiveView.Id });
Expand All @@ -79,7 +88,5 @@ public static IEnumerable<ElementId> ElementIdsByVisibleInActiveView(this Docume
}

/***************************************************/
}


}
}

0 comments on commit be9d97d

Please sign in to comment.