diff --git a/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs b/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs
index 47a922e26..0a51c612c 100644
--- a/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs
+++ b/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs
@@ -2,7 +2,7 @@
using Autodesk.DesignScript.Runtime;
using Autodesk.Revit.DB;
using Revit.Elements.Views;
-using AbstractView3D = Revit.Elements.Views.AbstractView3D;
+using View3D = Revit.Elements.Views.View3D;
namespace Revit.Elements
{
@@ -151,14 +151,16 @@ public static WallType Wrap(Autodesk.Revit.DB.WallType ele, bool isRevitOwned)
return WallType.FromExisting(ele, isRevitOwned);
}
- public static AbstractView3D Wrap(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
+ public static View3D Wrap(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
{
- if (view.IsTemplate)
- return Revit.Elements.Views.View3D.FromExisting(view, isRevitOwned);
- if (view.IsPerspective)
- return PerspectiveView.FromExisting(view, isRevitOwned);
-
- return AxonometricView.FromExisting(view, isRevitOwned);
+ if (!view.IsTemplate)
+ {
+ if (view.IsPerspective)
+ return PerspectiveView.FromExisting(view, isRevitOwned);
+ else
+ return AxonometricView.FromExisting(view, isRevitOwned);
+ }
+ return null;
}
public static Element Wrap(Autodesk.Revit.DB.ViewPlan view, bool isRevitOwned)
diff --git a/src/Libraries/RevitNodes/Elements/Views/AbstractView3D.cs b/src/Libraries/RevitNodes/Elements/Views/AbstractView3D.cs
deleted file mode 100644
index 20671d363..000000000
--- a/src/Libraries/RevitNodes/Elements/Views/AbstractView3D.cs
+++ /dev/null
@@ -1,515 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Autodesk.DesignScript.Runtime;
-using Autodesk.Revit.DB;
-using RevitServices.Persistence;
-using RevitServices.Transactions;
-
-namespace Revit.Elements.Views
-{
- [IsVisibleInDynamoLibrary(false)]
- [DynamoServices.RegisterForTrace]
- public abstract class AbstractView3D : View
- {
- [IsVisibleInDynamoLibrary(false)]
- public const string DefaultViewName = "dynamo3D";
-
- #region Internal properties
-
- ///
- /// An internal handle on the Revit element
- ///
- internal Autodesk.Revit.DB.View3D InternalView3D
- {
- get;
- private set;
- }
-
- ///
- /// Reference to the Element
- ///
- public override Autodesk.Revit.DB.Element InternalElement
- {
- get { return InternalView3D; }
- }
-
- #endregion
-
- #region Private helper methods
-
- ///
- /// Build Orientation3D object for eye point and a target point
- ///
- ///
- ///
- ///
- protected static ViewOrientation3D BuildOrientation3D(XYZ eyePoint, XYZ target)
- {
- var globalUp = XYZ.BasisZ;
- var direction = target.Subtract(eyePoint).Normalize();
-
- // If the direction is zero length (ex. the eye and target
- // points are coincident) than set the direction to look
- // along the x axis by default. Otherwise, the call to
- // create a ViewOrientation3D object will fail.
- if (direction.IsZeroLength())
- {
- direction = XYZ.BasisX;
- }
-
- // If the direction points along Z, then
- // switch the global up to Y
- if (direction.IsAlmostEqualTo(globalUp) ||
- (direction.Negate().IsAlmostEqualTo(globalUp)))
- {
- globalUp = XYZ.BasisY;
- }
-
- var up = direction.CrossProduct(globalUp).CrossProduct(direction);
-
- if (up.IsZeroLength())
- {
- up = XYZ.BasisZ;
- }
-
- // If up is zero length (ex. the direction vector is the z axis),
- // set the up to be along the Z axis.
- return new ViewOrientation3D(eyePoint, up, direction);
-
- }
-
- ///
- /// Obtain a sparse point collection outlining a Revit element bt traversing it's
- /// GeometryObject representation
- ///
- ///
- ///
- protected static void GetPointCloud(Autodesk.Revit.DB.Element e, List pts)
- {
- var options = new Options
- {
- ComputeReferences = true,
- DetailLevel = ViewDetailLevel.Coarse,
- IncludeNonVisibleObjects = false
- };
-
- foreach (var gObj in e.get_Geometry(options))
- {
- if (gObj is Solid)
- {
- GetPointCloud(gObj as Solid, pts);
- }
- else if (gObj is GeometryInstance)
- {
- GetPointCloud(gObj as GeometryInstance, pts);
- }
- }
- }
-
- ///
- /// Obtain a point collection outlining a GeometryObject
- ///
- ///
- ///
- protected static void GetPointCloud(GeometryInstance geomInst, List pts)
- {
- foreach (var gObj in geomInst.GetInstanceGeometry())
- {
- if (gObj is Solid)
- {
- GetPointCloud(gObj as Solid, pts);
- }
- else if (gObj is GeometryInstance)
- {
- GetPointCloud(gObj as GeometryInstance, pts);
- }
- }
- }
-
- ///
- /// Obtain a point collection outlining a Solid GeometryObject
- ///
- ///
- ///
- protected static void GetPointCloud(Solid solid, List pts)
- {
- foreach (Edge gEdge in solid.Edges)
- {
- var c = gEdge.AsCurve();
- if (c is Line)
- {
- pts.Add(c.Evaluate(0, true));
- pts.Add(c.Evaluate(1, true));
- }
- else
- {
- IList xyzArray = gEdge.Tessellate();
- pts.AddRange(xyzArray);
- }
- }
- }
-
- ///
- /// Make a single element appear in a particular view
- ///
- ///
- ///
- protected static void IsolateInView(Autodesk.Revit.DB.View3D view, Autodesk.Revit.DB.Element element)
- {
- var fec = GetVisibleElementFilter();
-
- view.CropBoxActive = true;
-
- var toHide =
- fec.ToElements().Where(x => !x.IsHidden(view) && x.CanBeHidden(view) && x.Id != element.Id).Select(x => x.Id).ToList();
-
- if (toHide.Count > 0)
- view.HideElements(toHide);
-
- DocumentManager.Regenerate();
-
- // After a regeneration, we need to ensure that a
- // transaction is re-opened.
- TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
-
- if (view.IsPerspective)
- {
- var farClip = view.LookupParameter("Far Clip Active");
- farClip.Set(0);
- }
- else
- {
- var pts = new List();
-
- GetPointCloud(element, pts);
-
- var bounding = view.CropBox;
- var transInverse = bounding.Transform.Inverse;
- var transPts = pts.Select(transInverse.OfPoint);
-
- //ingore the Z coordindates and find
- //the max X ,Y and Min X, Y in 3d view.
- double dMaxX = 0, dMaxY = 0, dMinX = 0, dMinY = 0;
-
- var bFirstPt = true;
- foreach (var pt1 in transPts)
- {
- if (bFirstPt)
- {
- dMaxX = pt1.X;
- dMaxY = pt1.Y;
- dMinX = pt1.X;
- dMinY = pt1.Y;
- bFirstPt = false;
- }
- else
- {
- if (dMaxX < pt1.X)
- dMaxX = pt1.X;
- if (dMaxY < pt1.Y)
- dMaxY = pt1.Y;
- if (dMinX > pt1.X)
- dMinX = pt1.X;
- if (dMinY > pt1.Y)
- dMinY = pt1.Y;
- }
- }
-
- bounding.Max = new XYZ(dMaxX, dMaxY, bounding.Max.Z);
- bounding.Min = new XYZ(dMinX, dMinY, bounding.Min.Z);
- view.CropBox = bounding;
- }
-
- view.CropBoxVisible = false;
-
- }
-
- ///
- /// Set the cropping for the current view
- ///
- ///
- ///
- private void IsolateInView(Autodesk.Revit.DB.View3D view3D, BoundingBoxXYZ bbox)
- {
- view3D.CropBox = bbox;
- }
-
- ///
- /// Create a Revit 3D View
- ///
- ///
- ///
- ///
- ///
- protected static Autodesk.Revit.DB.View3D Create3DView(ViewOrientation3D orient, string name, bool isPerspective)
- {
- // (sic) From the Dynamo legacy implementation
- var viewFam = DocumentManager.Instance.ElementsOfType()
- .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional);
-
- if (viewFam == null)
- {
- throw new Exception("There is no three dimensional view family int he document");
- }
-
- var view = isPerspective
- ? Autodesk.Revit.DB.View3D.CreatePerspective(Document, viewFam.Id)
- : Autodesk.Revit.DB.View3D.CreateIsometric(Document, viewFam.Id);
-
- view.SetOrientation(orient);
- view.SaveOrientationAndLock();
- view.Name = CreateUniqueViewName(name);
-
- return view;
- }
-
- ///
- /// Determines whether a view with the provided name already exists.
- /// If a view exists with the provided name, and new view is created with
- /// a unique name. Otherwise, the original view name is returned.
- ///
- ///
- /// The original name if it is already unique, or
- /// a unique version of the name.
- public static string CreateUniqueViewName(string name)
- {
- var collector = new FilteredElementCollector(Document);
- collector.OfClass(typeof(Autodesk.Revit.DB.View));
-
- // If the name is already unique then return it.
- if (collector.All(x => x.Name != name))
- return name;
-
- // Create a unique name by appending a guid to
- // the end of the view name
- var viewName = $"{name}_{Guid.NewGuid()}";
-
- return viewName;
- }
-
- ///
- /// Utility method to create a filtered element collector which collects all elements in a view
- /// which Dynamo would like to view or on which Dynamo would like to operate.
- ///
- ///
- protected static FilteredElementCollector GetVisibleElementFilter()
- {
- var fec = new FilteredElementCollector(Document);
- var filterList = new List();
-
- var fContinuousRail = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.ContinuousRail));
- var fRailing = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.Railing));
- var fStairs = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.Stairs));
- var fStairsLanding = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsLanding));
- var fTopographySurface = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.TopographySurface));
- var fAssemblyInstance = new ElementClassFilter(typeof(AssemblyInstance));
- var fBaseArray = new ElementClassFilter(typeof(BaseArray));
- var fBeamSystem = new ElementClassFilter(typeof(BeamSystem));
- var fBoundaryConditions = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.BoundaryConditions));
- var fConnectorElement = new ElementClassFilter(typeof(ConnectorElement));
- var fControl = new ElementClassFilter(typeof(Control));
- var fCurveElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.CurveElement));
- var fDividedSurface = new ElementClassFilter(typeof(Autodesk.Revit.DB.DividedSurface));
- var fCableTrayConduitRunBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.Electrical.CableTrayConduitRunBase));
- var fHostObject = new ElementClassFilter(typeof(HostObject));
- var fInstance = new ElementClassFilter(typeof(Instance));
- var fmepSystem = new ElementClassFilter(typeof(MEPSystem));
- var fModelText = new ElementClassFilter(typeof(Autodesk.Revit.DB.ModelText));
- var fOpening = new ElementClassFilter(typeof(Opening));
- var fPart = new ElementClassFilter(typeof(Part));
- var fPartMaker = new ElementClassFilter(typeof(PartMaker));
- var fReferencePlane = new ElementClassFilter(typeof(Autodesk.Revit.DB.ReferencePlane));
- var fReferencePoint = new ElementClassFilter(typeof(Autodesk.Revit.DB.ReferencePoint));
- var fSpatialElement = new ElementClassFilter(typeof(SpatialElement));
- var fAreaReinforcement = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.AreaReinforcement));
- var fHub = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Hub));
- var fPathReinforcement = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.PathReinforcement));
- var fRebar = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Rebar));
- var fTruss = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Truss));
-
- #region Unused
- //Autodesk.Revit.DB.Analysis.AnalysisDisplayLegend;
- //Autodesk.Revit.DB.Analysis.AnalysisDisplayStyle;
- //Autodesk.Revit.DB.Analysis.MassEnergyAnalyticalModel;
- //Autodesk.Revit.DB.Analysis.MassLevelData;
- //Autodesk.Revit.DB.Analysis.MassSurfaceData;
- //Autodesk.Revit.DB.Analysis.MassZone;
- //Autodesk.Revit.DB.Analysis.SpatialFieldManager;
- //Autodesk.Revit.DB.AreaScheme;
- //Autodesk.Revit.DB.AppearanceAssetElement;
- //var FStairsPath = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsPath));
- //var FStairsRun = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsRun));
- //Autodesk.Revit.DB.AreaScheme;
- //ElementClassFilter FBasePoint = new ElementClassFilter(typeof(Autodesk.Revit.DB.BasePoint));
- //ElementClassFilter FCombinableElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.CombinableElement));
- //Autodesk.Revit.DB..::..ComponentRepeater
- //Autodesk.Revit.DB..::..ComponentRepeaterSlot
- //Autodesk.Revit.DB.DesignOption;
- //Autodesk.Revit.DB.Dimension;
- //Autodesk.Revit.DB..::..DisplacementElement
- //Autodesk.Revit.DB.Electrical.ElectricalDemandFactorDefinition;
- //Autodesk.Revit.DB.Electrical.ElectricalLoadClassification;
- //Autodesk.Revit.DB.Electrical.PanelScheduleSheetInstance;
- //Autodesk.Revit.DB.Electrical.PanelScheduleTemplate;
- //var fElementType = new ElementClassFilter(typeof(ElementType));
- //Autodesk.Revit.DB..::..ElevationMarker
- //ElementClassFilter FFamilyBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.FamilyBase));
- //Autodesk.Revit.DB.FilledRegion;
- //Autodesk.Revit.DB.FillPatternElement;
- //Autodesk.Revit.DB.FilterElement;
- //Autodesk.Revit.DB.GraphicsStyle;
- //Autodesk.Revit.DB.Grid;
- //ElementClassFilter FGroup = new ElementClassFilter(typeof(Autodesk.Revit.DB.Group));
- //Autodesk.Revit.DB.IndependentTag;
- //Autodesk.Revit.DB.Level;
- //Autodesk.Revit.DB.LinePatternElement;
- //Autodesk.Revit.DB.Material;
- //Autodesk.Revit.DB.Mechanical.Zone;
- //Autodesk.Revit.DB..::..MultiReferenceAnnotation
- //Autodesk.Revit.DB.Phase;
- //Autodesk.Revit.DB..::..PhaseFilter
- //Autodesk.Revit.DB.PrintSetting;
- //Autodesk.Revit.DB.ProjectInfo;
- //Autodesk.Revit.DB.PropertyLine;
- //ElementClassFilter FPropertySetElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.PropertySetElement));
- //Autodesk.Revit.DB.PropertySetLibrary;
- //Autodesk.Revit.DB..::..ScheduleSheetInstance
- //Autodesk.Revit.DB..::..Segment
- //ElementClassFilter FSketchBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.SketchBase));
- //ElementClassFilter FSketchPlane = new ElementClassFilter(typeof(Autodesk.Revit.DB.SketchPlane));
- //Autodesk.Revit.DB..::..SpatialElementCalculationLocation
- //ElementClassFilter FSpatialElementTag = new ElementClassFilter(typeof(Autodesk.Revit.DB.SpatialElementTag));
- //Autodesk.Revit.DB.Structure..::..AnalyticalLink
- //Autodesk.Revit.DB.Structure.AnalyticalModel;
- //Autodesk.Revit.DB.Structure..::..FabricArea
- //Autodesk.Revit.DB.Structure..::..FabricReinSpanSymbolControl
- //Autodesk.Revit.DB.Structure..::..FabricSheet
- //Autodesk.Revit.DB.Structure.LoadBase;
- //Autodesk.Revit.DB.Structure.LoadCase;
- //Autodesk.Revit.DB.Structure.LoadCombination;
- //Autodesk.Revit.DB.Structure.LoadNature;
- //Autodesk.Revit.DB.Structure.LoadUsage;
- //Autodesk.Revit.DB.Structure..::..RebarInSystem
- //Autodesk.Revit.DB.SunAndShadowSettings;
- //Autodesk.Revit.DB.TextElement;
- //Autodesk.Revit.DB.View;
- //Autodesk.Revit.DB..::..Viewport
- //Autodesk.Revit.DB.ViewSheetSet;
- //Autodesk.Revit.DB.WorksharingDisplaySettings;
- #endregion
-
- filterList.Add(fContinuousRail);
- filterList.Add(fRailing);
- filterList.Add(fStairs);
- filterList.Add(fStairsLanding);
- filterList.Add(fTopographySurface);
- filterList.Add(fAssemblyInstance);
- filterList.Add(fBaseArray);
- filterList.Add(fBeamSystem);
- filterList.Add(fBoundaryConditions);
- filterList.Add(fConnectorElement);
- filterList.Add(fControl);
- filterList.Add(fCurveElement);
- filterList.Add(fDividedSurface);
- filterList.Add(fCableTrayConduitRunBase);
- filterList.Add(fHostObject);
- filterList.Add(fInstance);
- filterList.Add(fmepSystem);
- filterList.Add(fModelText);
- filterList.Add(fOpening);
- filterList.Add(fPart);
- filterList.Add(fPartMaker);
- filterList.Add(fReferencePlane);
- filterList.Add(fReferencePoint);
- filterList.Add(fAreaReinforcement);
- filterList.Add(fHub);
- filterList.Add(fPathReinforcement);
- filterList.Add(fRebar);
- filterList.Add(fTruss);
- filterList.Add(fSpatialElement);
-
- var cRvtLinks = new ElementCategoryFilter(BuiltInCategory.OST_RvtLinks);
- filterList.Add(cRvtLinks);
-
- var filters = new LogicalOrFilter(filterList);
- fec.WherePasses(filters).WhereElementIsNotElementType();
-
- return fec;
- }
-
- #endregion
-
- #region Protected mutators
-
- ///
- /// Set the name of the current view
- ///
- ///
- protected void InternalSetName(string name)
- {
- if (name == DefaultViewName && InternalView3D.Name.Contains(DefaultViewName + "_"))
- {
- // Assume that this has already been set unique.
- return;
- }
-
- if (!InternalView3D.Name.Equals(name))
- InternalView3D.Name = CreateUniqueViewName(name);
- }
-
- ///
- /// Set the orientation of the view
- ///
- ///
- protected void InternalSetOrientation(ViewOrientation3D orient)
- {
- if (InternalView3D.ViewDirection.IsAlmostEqualTo(-orient.ForwardDirection) &&
- InternalView3D.Origin.IsAlmostEqualTo(orient.EyePosition)) return;
-
- InternalView3D.Unlock();
- InternalView3D.SetOrientation(orient);
- InternalView3D.SaveOrientationAndLock();
- }
-
- ///
- /// Isolate the element in the current view by creating a mininum size crop box around it
- ///
- ///
- protected void InternalIsolateInView(Autodesk.Revit.DB.Element element)
- {
- IsolateInView(InternalView3D, element);
- }
-
- ///
- /// Isolate the bounding box in the current view
- ///
- ///
- protected void InternalIsolateInView(BoundingBoxXYZ bbox)
- {
- IsolateInView(InternalView3D, bbox);
- }
-
- ///
- /// Show all hiddent elements in the view
- ///
- protected void InternalRemoveIsolation()
- {
- InternalView3D.UnhideElements(GetVisibleElementFilter().ToElementIds());
- InternalView3D.CropBoxActive = false;
- }
-
- ///
- /// Set the InternalView3D property and the associated element id and unique id
- ///
- ///
- protected void InternalSetView3D(Autodesk.Revit.DB.View3D view)
- {
- InternalView3D = view;
- InternalElementId = view.Id;
- InternalUniqueId = view.UniqueId;
- }
-
- #endregion
- }
-}
diff --git a/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs b/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs
index 09c3bff31..32196c382 100644
--- a/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs
@@ -1,7 +1,11 @@
using System;
+
using Autodesk.Revit.DB;
+
using DynamoServices;
+
using Revit.GeometryConversion;
+
using RevitServices.Persistence;
using RevitServices.Transactions;
@@ -11,7 +15,7 @@ namespace Revit.Elements.Views
/// A Revit View3D
///
[RegisterForTrace]
- public class AxonometricView : AbstractView3D
+ public class AxonometricView : View3D
{
#region Private constructors
@@ -26,7 +30,7 @@ private AxonometricView(Autodesk.Revit.DB.View3D view)
///
/// Private constructor
///
- private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DefaultViewName,
+ private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DEFAULT_VIEW_NAME,
bool isolate = false)
{
SafeInit(() => InitAxonometricView(eye, target, bbox, name, isolate));
@@ -35,7 +39,7 @@ private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name =
///
/// Private constructor
///
- private AxonometricView(XYZ eye, XYZ target, string name = DefaultViewName, Autodesk.Revit.DB.Element element = null, bool isolate = false)
+ private AxonometricView(XYZ eye, XYZ target, string name = DEFAULT_VIEW_NAME, Autodesk.Revit.DB.Element element = null, bool isolate = false)
{
SafeInit(() => InitAxonometricView(eye, target, name, element, isolate));
}
@@ -55,7 +59,7 @@ private void InitAxonometricView(Autodesk.Revit.DB.View3D view)
///
/// Initialize an AxonometricView element
///
- private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DefaultViewName, bool isolate = false)
+ private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DEFAULT_VIEW_NAME, bool isolate = false)
{
//Phase 1 - Check to see if the object exists and should be rebound
var oldEle =
@@ -87,7 +91,7 @@ private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, strin
///
/// Initialize an AxonometricView element
///
- private void InitAxonometricView(XYZ eye, XYZ target, string name = DefaultViewName, Autodesk.Revit.DB.Element element = null, bool isolate = false)
+ private void InitAxonometricView(XYZ eye, XYZ target, string name = DEFAULT_VIEW_NAME, Autodesk.Revit.DB.Element element = null, bool isolate = false)
{
//Phase 1 - Check to see if the object exists and should be rebound
var oldEle =
@@ -126,7 +130,7 @@ private void InternalSetIsolation(Autodesk.Revit.DB.Element element, bool isolat
InternalRemoveIsolation();
}
- private void InternalSetIsolation(BoundingBoxXYZ bbox, bool isolate)
+ private void InternalSetIsolation(Autodesk.Revit.DB.BoundingBoxXYZ bbox, bool isolate)
{
if (isolate && bbox != null)
InternalIsolateInView(bbox);
@@ -147,7 +151,7 @@ private void InternalSetIsolation(BoundingBoxXYZ bbox, bool isolate)
public static AxonometricView ByEyePointAndTarget(
Autodesk.DesignScript.Geometry.Point eyePoint,
Autodesk.DesignScript.Geometry.Point target,
- string name = DefaultViewName)
+ string name = DEFAULT_VIEW_NAME)
{
if (eyePoint == null)
throw new ArgumentNullException("eyePoint");
@@ -157,7 +161,7 @@ public static AxonometricView ByEyePointAndTarget(
if (name == null)
{
- name = DefaultViewName;
+ name = DEFAULT_VIEW_NAME;
}
return ByEyePointTargetAndElement(eyePoint,
@@ -179,7 +183,7 @@ public static AxonometricView ByEyePointAndTarget(
public static AxonometricView ByEyePointTargetAndElement(
Autodesk.DesignScript.Geometry.Point eyePoint,
Autodesk.DesignScript.Geometry.Point target,
- string name = DefaultViewName,
+ string name = DEFAULT_VIEW_NAME,
Element element = null,
bool isolateElement = false)
{
@@ -191,7 +195,7 @@ public static AxonometricView ByEyePointTargetAndElement(
if (name == null)
{
- name = DefaultViewName;
+ name = DEFAULT_VIEW_NAME;
}
if (element == null)
@@ -229,7 +233,7 @@ public static AxonometricView ByEyePointTargetAndElement(
public static AxonometricView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint,
Autodesk.DesignScript.Geometry.Point target,
Autodesk.DesignScript.Geometry.BoundingBox boundingBox,
- string name = DefaultViewName,
+ string name = DEFAULT_VIEW_NAME,
bool isolateElement = false)
{
if (boundingBox == null)
@@ -245,7 +249,7 @@ public static AxonometricView ByEyePointTargetAndBoundingBox(Autodesk.DesignScri
if (name == null)
{
- name = DefaultViewName;
+ name = DEFAULT_VIEW_NAME;
}
return new AxonometricView(eyePoint.ToXyz(true), target.ToXyz(true), boundingBox.ToRevitType(true), name, isolateElement);
diff --git a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs
index 0f53472ab..4549520a5 100644
--- a/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/DraftingView.cs
@@ -82,7 +82,7 @@ private void InitDraftingView(string name)
//rename the view
if (!vd.Name.Equals(name))
- vd.Name = AbstractView3D.CreateUniqueViewName(name);
+ vd.Name = View3D.CreateUniqueViewName(name);
InternalSetDraftingView(vd);
diff --git a/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs b/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs
index 0e55194ae..0df3d3c49 100644
--- a/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs
@@ -15,7 +15,7 @@ namespace Revit.Elements.Views
/// A Revit View3D
///
[RegisterForTrace]
- public class PerspectiveView : AbstractView3D
+ public class PerspectiveView : View3D
{
#region Private constructors
diff --git a/src/Libraries/RevitNodes/Elements/Views/View3D.cs b/src/Libraries/RevitNodes/Elements/Views/View3D.cs
index fe543a248..2f32c24c4 100644
--- a/src/Libraries/RevitNodes/Elements/Views/View3D.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/View3D.cs
@@ -1,59 +1,532 @@
using System;
-using DynamoServices;
+using System.Collections.Generic;
+using System.Linq;
+using Autodesk.DesignScript.Runtime;
+using Autodesk.Revit.DB;
+using RevitServices.Persistence;
+using RevitServices.Transactions;
namespace Revit.Elements.Views
{
- ///
- /// A Revit View3D
- ///
- [RegisterForTrace]
- public class View3D : AbstractView3D
+ public abstract class View3D : View
{
- #region Private constructors
+ [IsVisibleInDynamoLibrary(false)]
+ public const string DEFAULT_VIEW_NAME = "dynamo3D";
+
+ #region Internal properties
///
- /// Private constructor
+ /// An internal handle on the Revit element
///
- private View3D(Autodesk.Revit.DB.View3D view)
+ internal Autodesk.Revit.DB.View3D InternalView3D
{
- SafeInit(() => Init3DView(view));
+ get;
+ private set;
+ }
+
+ ///
+ /// Reference to the Element
+ ///
+ public override Autodesk.Revit.DB.Element InternalElement
+ {
+ get { return InternalView3D; }
}
#endregion
- #region Helpers for private constructors
+ #region Private helper methods
///
- /// Initialize a 3d view
+ /// Build Orientation3D object for eye point and a target point
///
- private void Init3DView(Autodesk.Revit.DB.View3D view)
+ ///
+ ///
+ ///
+ protected static ViewOrientation3D BuildOrientation3D(XYZ eyePoint, XYZ target)
{
- InternalSetView3D(view);
+ var globalUp = XYZ.BasisZ;
+ var direction = target.Subtract(eyePoint).Normalize();
+
+ // If the direction is zero length (ex. the eye and target
+ // points are coincident) than set the direction to look
+ // along the x axis by default. Otherwise, the call to
+ // create a ViewOrientation3D object will fail.
+ if (direction.IsZeroLength())
+ {
+ direction = XYZ.BasisX;
+ }
+
+ // If the direction points along Z, then
+ // switch the global up to Y
+ if (direction.IsAlmostEqualTo(globalUp) ||
+ (direction.Negate().IsAlmostEqualTo(globalUp)))
+ {
+ globalUp = XYZ.BasisY;
+ }
+
+ var up = direction.CrossProduct(globalUp).CrossProduct(direction);
+
+ if (up.IsZeroLength())
+ {
+ up = XYZ.BasisZ;
+ }
+
+ // If up is zero length (ex. the direction vector is the z axis),
+ // set the up to be along the Z axis.
+ return new ViewOrientation3D(eyePoint, up, direction);
+
}
- #endregion
+ ///
+ /// Obtain a sparse point collection outlining a Revit element bt traversing it's
+ /// GeometryObject representation
+ ///
+ ///
+ ///
+ protected static void GetPointCloud(Autodesk.Revit.DB.Element e, List pts)
+ {
+ var options = new Options()
+ {
+ ComputeReferences = true,
+ DetailLevel = ViewDetailLevel.Coarse,
+ IncludeNonVisibleObjects = false
+ };
+
+ foreach (var gObj in e.get_Geometry(options))
+ {
+ if (gObj is Autodesk.Revit.DB.Solid)
+ {
+ GetPointCloud(gObj as Autodesk.Revit.DB.Solid, pts);
+ }
+ else if (gObj is GeometryInstance)
+ {
+ GetPointCloud(gObj as GeometryInstance, pts);
+ }
+ }
+ }
+
+ ///
+ /// Obtain a point collection outlining a GeometryObject
+ ///
+ ///
+ ///
+ protected static void GetPointCloud(GeometryInstance geomInst, List pts)
+ {
+ foreach (var gObj in geomInst.GetInstanceGeometry())
+ {
+ if (gObj is Autodesk.Revit.DB.Solid)
+ {
+ GetPointCloud(gObj as Autodesk.Revit.DB.Solid, pts);
+ }
+ else if (gObj is GeometryInstance)
+ {
+ GetPointCloud(gObj as GeometryInstance, pts);
+ }
+ }
+ }
- #region Internal methods
+ ///
+ /// Obtain a point collection outlining a Solid GeometryObject
+ ///
+ ///
+ ///
+ protected static void GetPointCloud(Autodesk.Revit.DB.Solid solid, List pts)
+ {
+ foreach (Edge gEdge in solid.Edges)
+ {
+ var c = gEdge.AsCurve();
+ if (c is Line)
+ {
+ pts.Add(c.Evaluate(0, true));
+ pts.Add(c.Evaluate(1, true));
+ }
+ else
+ {
+ IList xyzArray = gEdge.Tessellate();
+ pts.AddRange(xyzArray);
+ }
+ }
+ }
///
- /// Create from existing view
+ /// Make a single element appear in a particular view
///
///
- ///
+ ///
+ protected static void IsolateInView(Autodesk.Revit.DB.View3D view, Autodesk.Revit.DB.Element element)
+ {
+ var fec = GetVisibleElementFilter();
+
+ view.CropBoxActive = true;
+
+ var all = fec.ToElements();
+ var toHide =
+ fec.ToElements().Where(x => !x.IsHidden(view) && x.CanBeHidden(view) && x.Id != element.Id).Select(x => x.Id).ToList();
+
+ if (toHide.Count > 0)
+ view.HideElements(toHide);
+
+ DocumentManager.Regenerate();
+
+ // After a regeneration, we need to ensure that a
+ // transaction is re-opened.
+ TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
+
+ if (view.IsPerspective)
+ {
+ var farClip = view.LookupParameter("Far Clip Active");
+ farClip.Set(0);
+ }
+ else
+ {
+ var pts = new List();
+
+ GetPointCloud(element, pts);
+
+ var bounding = view.CropBox;
+ var transInverse = bounding.Transform.Inverse;
+ var transPts = pts.Select(transInverse.OfPoint);
+
+ //ingore the Z coordindates and find
+ //the max X ,Y and Min X, Y in 3d view.
+ double dMaxX = 0, dMaxY = 0, dMinX = 0, dMinY = 0;
+
+ bool bFirstPt = true;
+ foreach (var pt1 in transPts)
+ {
+ if (true == bFirstPt)
+ {
+ dMaxX = pt1.X;
+ dMaxY = pt1.Y;
+ dMinX = pt1.X;
+ dMinY = pt1.Y;
+ bFirstPt = false;
+ }
+ else
+ {
+ if (dMaxX < pt1.X)
+ dMaxX = pt1.X;
+ if (dMaxY < pt1.Y)
+ dMaxY = pt1.Y;
+ if (dMinX > pt1.X)
+ dMinX = pt1.X;
+ if (dMinY > pt1.Y)
+ dMinY = pt1.Y;
+ }
+ }
+
+ bounding.Max = new XYZ(dMaxX, dMaxY, bounding.Max.Z);
+ bounding.Min = new XYZ(dMinX, dMinY, bounding.Min.Z);
+ view.CropBox = bounding;
+ }
+
+ view.CropBoxVisible = false;
+
+ }
+
+ ///
+ /// Set the cropping for the current view
+ ///
+ ///
+ ///
+ private void IsolateInView(Autodesk.Revit.DB.View3D view3D, BoundingBoxXYZ bbox)
+ {
+ view3D.CropBox = bbox;
+ }
+
+ ///
+ /// Create a Revit 3D View
+ ///
+ ///
+ ///
+ ///
///
- internal static View3D FromExisting(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
+ protected static Autodesk.Revit.DB.View3D Create3DView(ViewOrientation3D orient, string name, bool isPerspective)
{
- if (view == null)
+ // (sic) From the Dynamo legacy implementation
+ var viewFam = DocumentManager.Instance.ElementsOfType()
+ .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional);
+
+ if (viewFam == null)
{
- throw new ArgumentNullException(nameof(view));
+ throw new Exception("There is no three dimensional view family int he document");
}
- return new View3D(view)
+ Autodesk.Revit.DB.View3D view;
+ if (isPerspective)
{
- IsRevitOwned = isRevitOwned
- };
+ view = Autodesk.Revit.DB.View3D.CreatePerspective(Document, viewFam.Id);
+ }
+ else
+ {
+ view = Autodesk.Revit.DB.View3D.CreateIsometric(Document, viewFam.Id);
+ }
+
+ view.SetOrientation(orient);
+ view.SaveOrientationAndLock();
+
+
+ view.Name = CreateUniqueViewName(name);
+
+ return view;
+ }
+
+ ///
+ /// Determines whether a view with the provided name already exists.
+ /// If a view exists with the provided name, and new view is created with
+ /// a unique name. Otherwise, the original view name is returned.
+ ///
+ ///
+ /// The original name if it is already unique, or
+ /// a unique version of the name.
+ public static string CreateUniqueViewName(string name)
+ {
+ var collector = new FilteredElementCollector(Document);
+ collector.OfClass(typeof(Autodesk.Revit.DB.View));
+
+ // If the name is already unique then return it.
+ if (collector.All(x => x.Name != name))
+ return name;
+
+ // Create a unique name by appending a guid to
+ // the end of the view name
+ var viewName = string.Format("{0}_{1}", name, Guid.NewGuid());
+
+ return viewName;
+ }
+
+ // (sic) From Dynamo legacy
+
+ ///
+ /// Utility method to create a filtered element collector which collects all elements in a view
+ /// which Dynamo would like to view or on which Dynamo would like to operate.
+ ///
+ ///
+ protected static FilteredElementCollector GetVisibleElementFilter()
+ {
+ var fec = new FilteredElementCollector(Document);
+ var filterList = new List();
+
+ //Autodesk.Revit.DB.Analysis.AnalysisDisplayLegend;
+ //Autodesk.Revit.DB.Analysis.AnalysisDisplayStyle;
+ //Autodesk.Revit.DB.Analysis.MassEnergyAnalyticalModel;
+ //Autodesk.Revit.DB.Analysis.MassLevelData;
+ //Autodesk.Revit.DB.Analysis.MassSurfaceData;
+ //Autodesk.Revit.DB.Analysis.MassZone;
+ //Autodesk.Revit.DB.Analysis.SpatialFieldManager;
+ //Autodesk.Revit.DB.AreaScheme;
+ //Autodesk.Revit.DB.AppearanceAssetElement;
+ var FContinuousRail = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.ContinuousRail));
+ var FRailing = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.Railing));
+ var FStairs = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.Stairs));
+ var FStairsLanding = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsLanding));
+ //var FStairsPath = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsPath));
+ //var FStairsRun = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.StairsRun));
+ var FTopographySurface = new ElementClassFilter(typeof(Autodesk.Revit.DB.Architecture.TopographySurface));
+ //Autodesk.Revit.DB.AreaScheme;
+ var FAssemblyInstance = new ElementClassFilter(typeof(Autodesk.Revit.DB.AssemblyInstance));
+ var FBaseArray = new ElementClassFilter(typeof(Autodesk.Revit.DB.BaseArray));
+ //ElementClassFilter FBasePoint = new ElementClassFilter(typeof(Autodesk.Revit.DB.BasePoint));
+ var FBeamSystem = new ElementClassFilter(typeof(Autodesk.Revit.DB.BeamSystem));
+ var FBoundaryConditions = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.BoundaryConditions));
+ //ElementClassFilter FCombinableElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.CombinableElement));
+ //Autodesk.Revit.DB..::..ComponentRepeater
+ //Autodesk.Revit.DB..::..ComponentRepeaterSlot
+ var FConnectorElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.ConnectorElement));
+ var FControl = new ElementClassFilter(typeof(Autodesk.Revit.DB.Control));
+ var FCurveElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.CurveElement));
+ //Autodesk.Revit.DB.DesignOption;
+ //Autodesk.Revit.DB.Dimension;
+ //Autodesk.Revit.DB..::..DisplacementElement
+ var FDividedSurface = new ElementClassFilter(typeof(Autodesk.Revit.DB.DividedSurface));
+ var FCableTrayConduitRunBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.Electrical.CableTrayConduitRunBase));
+ //Autodesk.Revit.DB.Electrical.ElectricalDemandFactorDefinition;
+ //Autodesk.Revit.DB.Electrical.ElectricalLoadClassification;
+ //Autodesk.Revit.DB.Electrical.PanelScheduleSheetInstance;
+ //Autodesk.Revit.DB.Electrical.PanelScheduleTemplate;
+ var FElementType = new ElementClassFilter(typeof(Autodesk.Revit.DB.ElementType));
+ //Autodesk.Revit.DB..::..ElevationMarker
+ //ElementClassFilter FFamilyBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.FamilyBase));
+ //Autodesk.Revit.DB.FilledRegion;
+ //Autodesk.Revit.DB.FillPatternElement;
+ //Autodesk.Revit.DB.FilterElement;
+ //Autodesk.Revit.DB.GraphicsStyle;
+ //Autodesk.Revit.DB.Grid;
+ //ElementClassFilter FGroup = new ElementClassFilter(typeof(Autodesk.Revit.DB.Group));
+ var FHostObject = new ElementClassFilter(typeof(Autodesk.Revit.DB.HostObject));
+ //Autodesk.Revit.DB.IndependentTag;
+ var FInstance = new ElementClassFilter(typeof(Autodesk.Revit.DB.Instance));
+ //Autodesk.Revit.DB.Level;
+ //Autodesk.Revit.DB.LinePatternElement;
+ //Autodesk.Revit.DB.Material;
+ //Autodesk.Revit.DB.Mechanical.Zone;
+ var FMEPSystem = new ElementClassFilter(typeof(Autodesk.Revit.DB.MEPSystem));
+ var FModelText = new ElementClassFilter(typeof(Autodesk.Revit.DB.ModelText));
+ //Autodesk.Revit.DB..::..MultiReferenceAnnotation
+ var FOpening = new ElementClassFilter(typeof(Autodesk.Revit.DB.Opening));
+ var FPart = new ElementClassFilter(typeof(Autodesk.Revit.DB.Part));
+ var FPartMaker = new ElementClassFilter(typeof(Autodesk.Revit.DB.PartMaker));
+ //Autodesk.Revit.DB.Phase;
+ //Autodesk.Revit.DB..::..PhaseFilter
+ //Autodesk.Revit.DB.PrintSetting;
+ //Autodesk.Revit.DB.ProjectInfo;
+ //Autodesk.Revit.DB.PropertyLine;
+ //ElementClassFilter FPropertySetElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.PropertySetElement));
+ //Autodesk.Revit.DB.PropertySetLibrary;
+ var FReferencePlane = new ElementClassFilter(typeof(Autodesk.Revit.DB.ReferencePlane));
+ var FReferencePoint = new ElementClassFilter(typeof(Autodesk.Revit.DB.ReferencePoint));
+ //Autodesk.Revit.DB..::..ScheduleSheetInstance
+ //Autodesk.Revit.DB..::..Segment
+ //ElementClassFilter FSketchBase = new ElementClassFilter(typeof(Autodesk.Revit.DB.SketchBase));
+ //ElementClassFilter FSketchPlane = new ElementClassFilter(typeof(Autodesk.Revit.DB.SketchPlane));
+ var FSpatialElement = new ElementClassFilter(typeof(Autodesk.Revit.DB.SpatialElement));
+ //Autodesk.Revit.DB..::..SpatialElementCalculationLocation
+ //ElementClassFilter FSpatialElementTag = new ElementClassFilter(typeof(Autodesk.Revit.DB.SpatialElementTag));
+ //Autodesk.Revit.DB.Structure..::..AnalyticalLink
+ //Autodesk.Revit.DB.Structure.AnalyticalModel;
+ var FAreaReinforcement = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.AreaReinforcement));
+ //Autodesk.Revit.DB.Structure..::..FabricArea
+ //Autodesk.Revit.DB.Structure..::..FabricReinSpanSymbolControl
+ //Autodesk.Revit.DB.Structure..::..FabricSheet
+ var FHub = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Hub));
+ //Autodesk.Revit.DB.Structure.LoadBase;
+ //Autodesk.Revit.DB.Structure.LoadCase;
+ //Autodesk.Revit.DB.Structure.LoadCombination;
+ //Autodesk.Revit.DB.Structure.LoadNature;
+ //Autodesk.Revit.DB.Structure.LoadUsage;
+ var FPathReinforcement = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.PathReinforcement));
+ var FRebar = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Rebar));
+ //Autodesk.Revit.DB.Structure..::..RebarInSystem
+ var FTruss = new ElementClassFilter(typeof(Autodesk.Revit.DB.Structure.Truss));
+ //Autodesk.Revit.DB.SunAndShadowSettings;
+ //Autodesk.Revit.DB.TextElement;
+ //Autodesk.Revit.DB.View;
+ //Autodesk.Revit.DB..::..Viewport
+ //Autodesk.Revit.DB.ViewSheetSet;
+ //Autodesk.Revit.DB.WorksharingDisplaySettings;
+
+ filterList.Add(FContinuousRail);
+ filterList.Add(FRailing);
+ filterList.Add(FStairs);
+ filterList.Add(FStairsLanding);
+ filterList.Add(FTopographySurface);
+ filterList.Add(FAssemblyInstance);
+ filterList.Add(FBaseArray);
+ filterList.Add(FBeamSystem);
+ filterList.Add(FBoundaryConditions);
+ filterList.Add(FConnectorElement);
+ filterList.Add(FControl);
+ filterList.Add(FCurveElement);
+ filterList.Add(FDividedSurface);
+ filterList.Add(FCableTrayConduitRunBase);
+ filterList.Add(FHostObject);
+ filterList.Add(FInstance);
+ filterList.Add(FMEPSystem);
+ filterList.Add(FModelText);
+ filterList.Add(FOpening);
+ filterList.Add(FPart);
+ filterList.Add(FPartMaker);
+ filterList.Add(FReferencePlane);
+ filterList.Add(FReferencePoint);
+ filterList.Add(FAreaReinforcement);
+ filterList.Add(FHub);
+ filterList.Add(FPathReinforcement);
+ filterList.Add(FRebar);
+ filterList.Add(FTruss);
+ filterList.Add(FSpatialElement);
+
+ //ElementCategoryFilter CRailings = new ElementCategoryFilter(BuiltInCategory.OST_StairsRailing);
+ //ElementCategoryFilter CStairs = new ElementCategoryFilter(BuiltInCategory.OST_Stairs);
+
+ var CRvtLinks = new ElementCategoryFilter(BuiltInCategory.OST_RvtLinks);
+ filterList.Add(CRvtLinks);
+
+ //List ignores = new List();
+ //ElementCategoryFilter CLightFixtureSource = new ElementCategoryFilter(BuiltInCategory.OST_LightingFixtureSource, true);
+ //ignores.Add(CLightFixtureSource);
+
+ var filters = new LogicalOrFilter(filterList);
+ //LogicalOrFilter exclusions = new LogicalOrFilter(ignores);
+
+ fec.WherePasses(filters).WhereElementIsNotElementType();
+
+ return fec;
}
#endregion
+
+ #region Protected mutators
+
+ ///
+ /// Set the name of the current view
+ ///
+ ///
+ protected void InternalSetName(string name)
+ {
+ if (name == DEFAULT_VIEW_NAME && InternalView3D.Name.Contains(DEFAULT_VIEW_NAME + "_"))
+ {
+ // Assume that this has already been set unique.
+ return;
+ }
+
+ if (!this.InternalView3D.Name.Equals(name))
+ this.InternalView3D.Name = CreateUniqueViewName(name);
+ }
+
+ ///
+ /// Set the orientation of the view
+ ///
+ ///
+ protected void InternalSetOrientation( ViewOrientation3D orient)
+ {
+ if (this.InternalView3D.ViewDirection.IsAlmostEqualTo(-orient.ForwardDirection) &&
+ this.InternalView3D.Origin.IsAlmostEqualTo(orient.EyePosition)) return;
+
+ this.InternalView3D.Unlock();
+ this.InternalView3D.SetOrientation(orient);
+ this.InternalView3D.SaveOrientationAndLock();
+ }
+
+ ///
+ /// Isolate the element in the current view by creating a mininum size crop box around it
+ ///
+ ///
+ protected void InternalIsolateInView(Autodesk.Revit.DB.Element element)
+ {
+ IsolateInView(this.InternalView3D, element);
+ }
+
+ ///
+ /// Isolate the bounding box in the current view
+ ///
+ ///
+ protected void InternalIsolateInView(BoundingBoxXYZ bbox)
+ {
+ IsolateInView(this.InternalView3D, bbox);
+ }
+
+ ///
+ /// Show all hiddent elements in the view
+ ///
+ protected void InternalRemoveIsolation()
+ {
+ InternalView3D.UnhideElements(GetVisibleElementFilter().ToElementIds());
+ InternalView3D.CropBoxActive = false;
+ }
+
+ ///
+ /// Set the InternalView3D property and the associated element id and unique id
+ ///
+ ///
+ protected void InternalSetView3D(Autodesk.Revit.DB.View3D view)
+ {
+ this.InternalView3D = view;
+ this.InternalElementId = view.Id;
+ this.InternalUniqueId = view.UniqueId;
+ }
+
+ #endregion
+
}
-}
\ No newline at end of file
+}
+
diff --git a/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs b/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs
index a5592b302..ab3a3bc75 100644
--- a/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs
+++ b/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs
@@ -22,7 +22,7 @@ public static class RayBounce
///
///
[MultiReturn(new[] { "points", "elements" })]
- public static Dictionary ByOriginDirection(Point origin, Vector direction, int maxBounces, Elements.Views.AbstractView3D view)
+ public static Dictionary ByOriginDirection(Point origin, Vector direction, int maxBounces, Elements.Views.View3D view)
{
var startpt = origin.ToXyz();
var rayCount = 0;
diff --git a/src/Libraries/RevitNodes/RevitNodes.csproj b/src/Libraries/RevitNodes/RevitNodes.csproj
index 7984833bc..8df099e10 100644
--- a/src/Libraries/RevitNodes/RevitNodes.csproj
+++ b/src/Libraries/RevitNodes/RevitNodes.csproj
@@ -105,7 +105,6 @@
-
diff --git a/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs b/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs
index 3b434d1a1..15da31ac9 100644
--- a/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs
+++ b/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs
@@ -77,7 +77,7 @@ public void ByEyePointAndTarget_DefaultArgs()
var target = Point.ByCoordinates(0, 1, 2);
var v = AxonometricView.ByEyePointAndTarget(eye, target);
- Assert.AreEqual(v.InternalElement.Name, AbstractView3D.DefaultViewName);
+ Assert.AreEqual(v.InternalElement.Name, View3D.DEFAULT_VIEW_NAME);
}
[Test]
@@ -129,7 +129,7 @@ public void ByEyePointTargetAndBoundingBox_DefaultArgs()
var v = AxonometricView.ByEyePointTargetAndBoundingBox(eye, target, famInst.BoundingBox);
var view = (Autodesk.Revit.DB.View3D)v.InternalElement;
- Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
+ Assert.AreEqual(view.Name, View3D.DEFAULT_VIEW_NAME);
Assert.False(view.CropBoxActive);
}
@@ -181,7 +181,7 @@ public void ByEyePointTargetAndElement_DefaultArgs()
var v = AxonometricView.ByEyePointTargetAndBoundingBox(eye, target, famInst.BoundingBox);
var view = (Autodesk.Revit.DB.View3D)v.InternalElement;
- Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
+ Assert.AreEqual(view.Name, View3D.DEFAULT_VIEW_NAME);
Assert.False(view.CropBoxActive);
}
}
diff --git a/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs b/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs
index 136cf6953..0f8a9597c 100644
--- a/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs
+++ b/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs
@@ -43,7 +43,7 @@ private static View CreateTestView()
var v = AxonometricView.ByEyePointAndTarget(eye, target);
var view = (Autodesk.Revit.DB.View3D)v.InternalElement;
- Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
+ Assert.AreEqual(view.Name, View3D.DEFAULT_VIEW_NAME);
Assert.False(view.CropBoxActive);
return v;