Ejemplo n.º 1
0
        /// <summary>
        /// This node will obtain the outline of the Viewport title if one is used. This is the label outline.
        /// </summary>
        /// <param name="viewport">Viewport to obtain data from.</param>
        /// <returns name="labelOutline">The label outline of the viewport.</returns>
        /// <search>
        /// viewport, Viewport.LabelOutline, rhythm
        /// </search>
        public static List <Autodesk.DesignScript.Geometry.Curve> LabelOutline(global::Revit.Elements.Element viewport)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            //obtain the element id from the sheet
            Autodesk.Revit.DB.Viewport internalViewport = (Autodesk.Revit.DB.Viewport)viewport.InternalElement;

            //this obtains the label outline
            var labelOutline = internalViewport.GetLabelOutline();
            //create plane that corresponds to sheet plane
            Plane labelPlane   = Plane.ByOriginNormal(labelOutline.MaximumPoint.ToPoint(), Vector.ZAxis());
            var   labelCuboid  = Cuboid.ByCorners(labelOutline.MaximumPoint.ToPoint(), labelOutline.MinimumPoint.ToPoint());
            var   labelSurface = labelCuboid.Intersect(labelPlane);
            List <Autodesk.DesignScript.Geometry.Curve[]> labelCurves = new List <Autodesk.DesignScript.Geometry.Curve[]>();

            foreach (Surface surf in labelSurface)
            {
                labelCurves.Add(surf.PerimeterCurves());
            }
            List <Autodesk.DesignScript.Geometry.Curve> labelSheetCurves = new List <Autodesk.DesignScript.Geometry.Curve>();

            //pull the curves onto a plane at 0,0,0
            foreach (Autodesk.DesignScript.Geometry.Curve[] curve in labelCurves)
            {
                foreach (Autodesk.DesignScript.Geometry.Curve c in curve)
                {
                    labelSheetCurves.Add(c.PullOntoPlane(Plane.XY()));
                }
            }

            return(labelSheetCurves);
        }
Ejemplo n.º 2
0
        public static Dictionary <string, object> LocationData(global::Revit.Elements.Element viewport)
        {
            //obtain the element id from the sheet
            Autodesk.Revit.DB.Viewport internalViewport = (Autodesk.Revit.DB.Viewport)viewport.InternalElement;
            //obtain the box center of the viewport
            var boxCenterInternal = internalViewport.GetBoxCenter().ToPoint();

            //Construct new point at sheet elevation of 0
            Autodesk.DesignScript.Geometry.Point boxCenter =
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(boxCenterInternal.X, boxCenterInternal.Y, 0);
            //this obtains the box outline
            var boxOutline = internalViewport.GetBoxOutline();
            //temporary geometry
            var bBox      = BoundingBox.ByCorners(boxOutline.MaximumPoint.ToPoint(), boxOutline.MinimumPoint.ToPoint());
            var boxCuboid = Cuboid.ByCorners(boxOutline.MaximumPoint.ToPoint(), boxOutline.MinimumPoint.ToPoint());
            //create plane that corresponds to sheet plane
            Plane boxPlane   = Plane.ByOriginNormal(boxOutline.MaximumPoint.ToPoint(), Vector.ZAxis());
            var   boxSurface = boxCuboid.Intersect(boxPlane);
            List <Autodesk.DesignScript.Geometry.Curve[]> boxCurves = new List <Autodesk.DesignScript.Geometry.Curve[]>();

            foreach (var geometry in boxSurface)
            {
                var surf = (Surface)geometry;
                boxCurves.Add(surf.PerimeterCurves());
                surf.Dispose();
            }
            List <Autodesk.DesignScript.Geometry.Curve> boxSheetCurves = new List <Autodesk.DesignScript.Geometry.Curve>();

            //pull the curves onto a plane at 0,0,0
            foreach (Autodesk.DesignScript.Geometry.Curve[] curve in boxCurves)
            {
                foreach (Autodesk.DesignScript.Geometry.Curve c in curve)
                {
                    boxSheetCurves.Add(c.PullOntoPlane(Plane.XY()));
                    c.Dispose();
                }
            }

            //dispose of temporary geometries
            boxCuboid.Dispose();
            boxPlane.Dispose();
            //returns the outputs
            var outInfo = new Dictionary <string, object>
            {
                { "bBox", bBox },
                { "boxCenter", boxCenter },
                { "boxOutline", boxSheetCurves }
            };

            return(outInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This node will get the bounds of the view in paper space (in feet).
        /// </summary>
        /// <param name="view">The view to get outline from.</param>
        /// <returns name="outline">The bounds of the view in paper space (in feet).</returns>
        /// <search>
        /// view, outline,rhythm
        /// </search>
        public static List <Autodesk.DesignScript.Geometry.Curve[]> GetOutline(global::Revit.Elements.Element view)
        {
            Autodesk.Revit.DB.View internalView = (Autodesk.Revit.DB.View)view.InternalElement;
            var viewBbox   = internalView.Outline;
            var viewCuboid = Cuboid.ByCorners(Point.ByCoordinates(viewBbox.Max.U, viewBbox.Max.V, 0),
                                              Point.ByCoordinates(viewBbox.Min.U, viewBbox.Min.V, 0));
            var viewOutlineSurface = viewCuboid.Intersect(Plane.XY());
            List <Autodesk.DesignScript.Geometry.Curve[]> viewOutlineCurves =
                new List <Autodesk.DesignScript.Geometry.Curve[]>();

            foreach (Surface surf in viewOutlineSurface)
            {
                viewOutlineCurves.Add(surf.PerimeterCurves());
            }

            return(viewOutlineCurves);
        }