diff --git a/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs b/src/Libraries/RevitNodes/Elements/InternalUtilities/ElementWrapper.cs
index 0a51c612c..47a922e26 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 View3D = Revit.Elements.Views.View3D;
+using AbstractView3D = Revit.Elements.Views.AbstractView3D;
namespace Revit.Elements
{
@@ -151,16 +151,14 @@ public static WallType Wrap(Autodesk.Revit.DB.WallType ele, bool isRevitOwned)
return WallType.FromExisting(ele, isRevitOwned);
}
- public static View3D Wrap(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
+ public static AbstractView3D Wrap(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
{
- if (!view.IsTemplate)
- {
- if (view.IsPerspective)
- return PerspectiveView.FromExisting(view, isRevitOwned);
- else
- return AxonometricView.FromExisting(view, isRevitOwned);
- }
- return null;
+ if (view.IsTemplate)
+ return Revit.Elements.Views.View3D.FromExisting(view, isRevitOwned);
+ if (view.IsPerspective)
+ return PerspectiveView.FromExisting(view, isRevitOwned);
+
+ return AxonometricView.FromExisting(view, isRevitOwned);
}
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
new file mode 100644
index 000000000..20671d363
--- /dev/null
+++ b/src/Libraries/RevitNodes/Elements/Views/AbstractView3D.cs
@@ -0,0 +1,515 @@
+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 32196c382..09c3bff31 100644
--- a/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/AxonometricView.cs
@@ -1,11 +1,7 @@
using System;
-
using Autodesk.Revit.DB;
-
using DynamoServices;
-
using Revit.GeometryConversion;
-
using RevitServices.Persistence;
using RevitServices.Transactions;
@@ -15,7 +11,7 @@ namespace Revit.Elements.Views
/// A Revit View3D
///
[RegisterForTrace]
- public class AxonometricView : View3D
+ public class AxonometricView : AbstractView3D
{
#region Private constructors
@@ -30,7 +26,7 @@ private AxonometricView(Autodesk.Revit.DB.View3D view)
///
/// Private constructor
///
- private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DEFAULT_VIEW_NAME,
+ private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DefaultViewName,
bool isolate = false)
{
SafeInit(() => InitAxonometricView(eye, target, bbox, name, isolate));
@@ -39,7 +35,7 @@ private AxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name =
///
/// Private constructor
///
- private AxonometricView(XYZ eye, XYZ target, string name = DEFAULT_VIEW_NAME, Autodesk.Revit.DB.Element element = null, bool isolate = false)
+ private AxonometricView(XYZ eye, XYZ target, string name = DefaultViewName, Autodesk.Revit.DB.Element element = null, bool isolate = false)
{
SafeInit(() => InitAxonometricView(eye, target, name, element, isolate));
}
@@ -59,7 +55,7 @@ private void InitAxonometricView(Autodesk.Revit.DB.View3D view)
///
/// Initialize an AxonometricView element
///
- private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DEFAULT_VIEW_NAME, bool isolate = false)
+ private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, string name = DefaultViewName, bool isolate = false)
{
//Phase 1 - Check to see if the object exists and should be rebound
var oldEle =
@@ -91,7 +87,7 @@ private void InitAxonometricView(XYZ eye, XYZ target, BoundingBoxXYZ bbox, strin
///
/// Initialize an AxonometricView element
///
- private void InitAxonometricView(XYZ eye, XYZ target, string name = DEFAULT_VIEW_NAME, Autodesk.Revit.DB.Element element = null, bool isolate = false)
+ private void InitAxonometricView(XYZ eye, XYZ target, string name = DefaultViewName, Autodesk.Revit.DB.Element element = null, bool isolate = false)
{
//Phase 1 - Check to see if the object exists and should be rebound
var oldEle =
@@ -130,7 +126,7 @@ private void InternalSetIsolation(Autodesk.Revit.DB.Element element, bool isolat
InternalRemoveIsolation();
}
- private void InternalSetIsolation(Autodesk.Revit.DB.BoundingBoxXYZ bbox, bool isolate)
+ private void InternalSetIsolation(BoundingBoxXYZ bbox, bool isolate)
{
if (isolate && bbox != null)
InternalIsolateInView(bbox);
@@ -151,7 +147,7 @@ private void InternalSetIsolation(Autodesk.Revit.DB.BoundingBoxXYZ bbox, bool is
public static AxonometricView ByEyePointAndTarget(
Autodesk.DesignScript.Geometry.Point eyePoint,
Autodesk.DesignScript.Geometry.Point target,
- string name = DEFAULT_VIEW_NAME)
+ string name = DefaultViewName)
{
if (eyePoint == null)
throw new ArgumentNullException("eyePoint");
@@ -161,7 +157,7 @@ public static AxonometricView ByEyePointAndTarget(
if (name == null)
{
- name = DEFAULT_VIEW_NAME;
+ name = DefaultViewName;
}
return ByEyePointTargetAndElement(eyePoint,
@@ -183,7 +179,7 @@ public static AxonometricView ByEyePointAndTarget(
public static AxonometricView ByEyePointTargetAndElement(
Autodesk.DesignScript.Geometry.Point eyePoint,
Autodesk.DesignScript.Geometry.Point target,
- string name = DEFAULT_VIEW_NAME,
+ string name = DefaultViewName,
Element element = null,
bool isolateElement = false)
{
@@ -195,7 +191,7 @@ public static AxonometricView ByEyePointTargetAndElement(
if (name == null)
{
- name = DEFAULT_VIEW_NAME;
+ name = DefaultViewName;
}
if (element == null)
@@ -233,7 +229,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 = DEFAULT_VIEW_NAME,
+ string name = DefaultViewName,
bool isolateElement = false)
{
if (boundingBox == null)
@@ -249,7 +245,7 @@ public static AxonometricView ByEyePointTargetAndBoundingBox(Autodesk.DesignScri
if (name == null)
{
- name = DEFAULT_VIEW_NAME;
+ name = DefaultViewName;
}
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 4549520a5..0f53472ab 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 = View3D.CreateUniqueViewName(name);
+ vd.Name = AbstractView3D.CreateUniqueViewName(name);
InternalSetDraftingView(vd);
diff --git a/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs b/src/Libraries/RevitNodes/Elements/Views/PerspectiveView.cs
index 0df3d3c49..0e55194ae 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 : View3D
+ public class PerspectiveView : AbstractView3D
{
#region Private constructors
diff --git a/src/Libraries/RevitNodes/Elements/Views/View3D.cs b/src/Libraries/RevitNodes/Elements/Views/View3D.cs
index 2f32c24c4..fe543a248 100644
--- a/src/Libraries/RevitNodes/Elements/Views/View3D.cs
+++ b/src/Libraries/RevitNodes/Elements/Views/View3D.cs
@@ -1,532 +1,59 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using Autodesk.DesignScript.Runtime;
-using Autodesk.Revit.DB;
-using RevitServices.Persistence;
-using RevitServices.Transactions;
+using DynamoServices;
namespace Revit.Elements.Views
{
- public abstract class View3D : View
+ ///
+ /// A Revit View3D
+ ///
+ [RegisterForTrace]
+ public class View3D : AbstractView3D
{
- [IsVisibleInDynamoLibrary(false)]
- public const string DEFAULT_VIEW_NAME = "dynamo3D";
-
- #region Internal properties
+ #region Private constructors
///
- /// An internal handle on the Revit element
+ /// Private constructor
///
- internal Autodesk.Revit.DB.View3D InternalView3D
+ private View3D(Autodesk.Revit.DB.View3D view)
{
- get;
- private set;
- }
-
- ///
- /// Reference to the Element
- ///
- public override Autodesk.Revit.DB.Element InternalElement
- {
- get { return InternalView3D; }
+ SafeInit(() => Init3DView(view));
}
#endregion
- #region Private helper methods
+ #region Helpers for private constructors
///
- /// Build Orientation3D object for eye point and a target point
+ /// Initialize a 3d view
///
- ///
- ///
- ///
- protected static ViewOrientation3D BuildOrientation3D(XYZ eyePoint, XYZ target)
+ private void Init3DView(Autodesk.Revit.DB.View3D 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);
-
+ InternalSetView3D(view);
}
- ///
- /// 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);
- }
- }
- }
+ #endregion
- ///
- /// 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);
- }
- }
- }
+ #region Internal methods
///
- /// Make a single element appear in a particular view
+ /// Create from existing 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
- ///
- ///
- ///
- ///
+ ///
///
- protected static Autodesk.Revit.DB.View3D Create3DView(ViewOrientation3D orient, string name, bool isPerspective)
+ internal static View3D FromExisting(Autodesk.Revit.DB.View3D view, bool isRevitOwned)
{
- // (sic) From the Dynamo legacy implementation
- var viewFam = DocumentManager.Instance.ElementsOfType()
- .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional);
-
- if (viewFam == null)
+ if (view == null)
{
- throw new Exception("There is no three dimensional view family int he document");
+ throw new ArgumentNullException(nameof(view));
}
- Autodesk.Revit.DB.View3D view;
- if (isPerspective)
+ return new View3D(view)
{
- 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;
+ IsRevitOwned = isRevitOwned
+ };
}
#endregion
-
}
-}
-
+}
\ No newline at end of file
diff --git a/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs b/src/Libraries/RevitNodes/GeometryReferences/RayBounce.cs
index ab3a3bc75..a5592b302 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.View3D view)
+ public static Dictionary ByOriginDirection(Point origin, Vector direction, int maxBounces, Elements.Views.AbstractView3D view)
{
var startpt = origin.ToXyz();
var rayCount = 0;
diff --git a/src/Libraries/RevitNodes/RevitNodes.csproj b/src/Libraries/RevitNodes/RevitNodes.csproj
index 8df099e10..7984833bc 100644
--- a/src/Libraries/RevitNodes/RevitNodes.csproj
+++ b/src/Libraries/RevitNodes/RevitNodes.csproj
@@ -105,6 +105,7 @@
+
diff --git a/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs b/test/Libraries/RevitNodesTests/Elements/Views/AxonometricViewTests.cs
index 15da31ac9..3b434d1a1 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, View3D.DEFAULT_VIEW_NAME);
+ Assert.AreEqual(v.InternalElement.Name, AbstractView3D.DefaultViewName);
}
[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, View3D.DEFAULT_VIEW_NAME);
+ Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
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, View3D.DEFAULT_VIEW_NAME);
+ Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
Assert.False(view.CropBoxActive);
}
}
diff --git a/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs b/test/Libraries/RevitNodesTests/Elements/Views/ViewTests.cs
index 0f8a9597c..136cf6953 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, View3D.DEFAULT_VIEW_NAME);
+ Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
Assert.False(view.CropBoxActive);
return v;