/// <summary> /// Set CropBox for a view. /// </summary> /// <param name="boundingBox"></param> /// <returns></returns> public View SetCropBox(Autodesk.DesignScript.Geometry.BoundingBox boundingBox) { RevitServices.Transactions.TransactionManager.Instance.EnsureInTransaction(Application.Document.Current.InternalDocument); InternalView.CropBox = boundingBox.ToRevitType(); RevitServices.Transactions.TransactionManager.Instance.TransactionTaskDone(); return(this); }
/// <summary> /// Create a Revit Perspective View from an Eye position, a target position, and /// either an Element or BoundingBox. /// </summary> /// <param name="eyePoint">A Point representing the eye point.</param> /// <param name="target">A Point representing the target of view.</param> /// <param name="element">This argument cannot be null, and it has to be either a /// Revit.Elements.Element or Revit.GeometryObjectsBoundingBox.</param> /// <param name="name">The name of the view.</param> /// <param name="isolateElement">If this argument is set to true, the element or /// bounding box will be isolated in the current view by creating a minimum size /// crop box around it.</param> /// <returns>Returns the resulting PerspectiveView object.</returns> /// public static PerspectiveView ByEyePointAndTarget( Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, object element, string name, bool isolateElement) { if (element == null) { throw new ArgumentNullException("element"); } Element abstractElement = element as Element; if (abstractElement != null) { return(ByEyePointTargetAndElement(eyePoint, target, abstractElement, name, isolateElement)); } Autodesk.DesignScript.Geometry.BoundingBox boundingBox = element as Autodesk.DesignScript.Geometry.BoundingBox; if (boundingBox != null) { return(ByEyePointTargetAndBoundingBox(eyePoint, target, boundingBox, name, isolateElement)); } string message = string.Format("Argument is expected to be of type " + "'Revit.Elements.AbstractElement' or ' Revit.GeometryObjectsBoundingBox', " + "but found to be of type '{0}'", element.GetType()); throw new ArgumentException(message, "element"); }
/// <summary> /// Create a Revit Axonometric (isometric) View from an Eye position and target position and Bounding Box /// </summary> /// <param name="eyePoint">A Point representing the eye point.</param> /// <param name="target">A Point representing the target of view.</param> /// <param name="boundingBox">A BoundingBox. The view will be cropped to this bounding box</param> /// <param name="name">The name of the view.</param> /// <param name="isolateElement">If this argument is set to true, the element or /// bounding box will be isolated in the current view by creating a minimum size /// crop box around it.</param> /// <returns>An AxonometricView object.</returns> public static AxonometricView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Autodesk.DesignScript.Geometry.BoundingBox boundingBox, string name = DEFAULT_VIEW_NAME, bool isolateElement = false) { if (boundingBox == null) { throw new ArgumentNullException("boundingBox"); } if (eyePoint == null) { throw new ArgumentNullException("eyePoint"); } if (target == null) { throw new ArgumentNullException("target"); } if (name == null) { name = DEFAULT_VIEW_NAME; } return(new AxonometricView(eyePoint.ToXyz(true), target.ToXyz(true), boundingBox.ToRevitType(true), name, isolateElement)); }
/// <summary> /// Create a Revit ViewSection by a bounding box /// </summary> /// <param name="box">The bounding box of the view in meters</param> /// <returns></returns> public static SectionView ByBoundingBox(Autodesk.DesignScript.Geometry.BoundingBox box) { if (box == null) { throw new ArgumentNullException("box"); } return(new SectionView(box.ToRevitType())); }
/// <summary> /// Create a Revit Perspective View from an Eye position and target position and Bounding Box /// </summary> /// <param name="eyePoint"></param> /// <param name="target"></param> /// <param name="boundingBox"></param> /// <param name="name"></param> /// <param name="isolateElement"></param> /// <returns></returns> public static PerspectiveView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Autodesk.DesignScript.Geometry.BoundingBox boundingBox, string name, bool isolateElement) { if (boundingBox == null) { throw new ArgumentNullException("boundingBox"); } if (eyePoint == null) { throw new ArgumentNullException("eyePoint"); } if (target == null) { throw new ArgumentNullException("target"); } if (name == null) { throw new ArgumentNullException("name"); } return(new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), boundingBox.ToRevitType(), name, isolateElement)); }
internal OctreeNode(int depth, BoundingBox bbox) { this.depth = depth; this.bbox = bbox; }
private static bool IsContainedIn(this IEnumerable <XYZ> curveLoop, BoundingBox boundingBox) { return(curveLoop.All(x => boundingBox.Contains(x.ToPoint(false)))); }
public static List <CurvePartition> ByCurveLoops(List <List <Curve> > curveLoops) { if (curveLoops.Count == 1) { return new List <CurvePartition>() { new CurvePartition() { OuterCurves = curveLoops[0] } } } ; var tesselatedCurveLoops = new List <Tuple <BoundingBox, List <XYZ>, List <Curve> > >(); foreach (var curveLoop in curveLoops) { var verts = TesselateCurveLoop(curveLoop).ToList(); List <Autodesk.DesignScript.Geometry.Curve> curves = new List <Autodesk.DesignScript.Geometry.Curve>(); foreach (var curve in curveLoop) { curves.Add(curve.ToProtoType(false)); } var geom = new List <Autodesk.DesignScript.Geometry.Geometry>(); geom.Add(PolyCurve.ByJoinedCurves(curves)); tesselatedCurveLoops.Add(new Tuple <BoundingBox, List <XYZ>, List <Curve> >(BoundingBox.ByGeometry(geom), verts, curveLoop)); curves.ForEach(x => x.Dispose()); curves.Clear(); geom.ForEach(x => x.Dispose()); geom.Clear(); } var outerCurveLoops = new List <Tuple <BoundingBox, List <XYZ>, List <Curve> > >(); var innerCurveLoops = new List <Tuple <BoundingBox, List <XYZ>, List <Curve> > >(); // collect the outer loops, which are not contained in any other loop for (int i = 0, j = tesselatedCurveLoops.Count - 1; i < tesselatedCurveLoops.Count; j = i++) { var curveLoop = tesselatedCurveLoops[i]; var isOuter = tesselatedCurveLoops.Where((_, l) => i != l) .All(bound => !curveLoop.Item2.IsContainedIn(bound.Item1)); if (isOuter) { outerCurveLoops.Add(curveLoop); } else { innerCurveLoops.Add(curveLoop); } } var curvesPartitions = new List <CurvePartition>(); // for each outer loop, collect the loops that are inside of it // forming the partitions of the original curve loop set foreach (var outerLoop in outerCurveLoops) { var comp = new List <List <Curve> > { outerLoop.Item3 }; var mask = new List <bool>(); var curvePatition = new CurvePartition(); curvePatition.OuterCurves.AddRange(outerLoop.Item3); foreach (var innerLoop in innerCurveLoops) { if (innerLoop.Item2.IsContainedIn(outerLoop.Item1)) { mask.Add(false); comp.Add(innerLoop.Item3); curvePatition.InnerCurves.Add(innerLoop.Item3); } else { mask.Add(true); } } // remove innerEdge loops that have already been added to a partition innerCurveLoops = innerCurveLoops.Where((_, j) => mask[j]).ToList(); // add the new partition curvesPartitions.Add(curvePatition); } return(curvesPartitions); }