Beispiel #1
0
        private static ViewBox getPlanViewBox(ViewPlan vp)
        {
            System.Diagnostics.Debug.WriteLine("ViewPlan: " + vp.Id + " Outline: " + vp.Outline.Min.U + "," + vp.Outline.Min.V + " to " + vp.Outline.Max.U + "," + vp.Outline.Max.V);
            System.Diagnostics.Debug.WriteLine("ViewPlan Scale: " + vp.Scale);


            XYZ tmp1 = vp.Origin.Add(new XYZ(vp.Outline.Min.U * (double)vp.Scale, vp.Outline.Min.V * (double)vp.Scale, 0));
            XYZ tmp2 = vp.Origin.Add(new XYZ(vp.Outline.Max.U * (double)vp.Scale, vp.Outline.Max.V * (double)vp.Scale, 0));

            // double check the cropbox, if it is smaller...
            if (vp.CropBoxActive)
            {
                tmp1 = vp.CropBox.Min;
                tmp2 = vp.CropBox.Max;
            }

            // in a plan view, we will work with the cropbox (if it is set?)
            ViewBox box = new ViewBox()
            {
                P1 = tmp1, P2 = tmp2
            };

            // now reset by the level and the viewdepth
            if (vp.GenLevel != null)
            {
                PlanViewRange pvr   = vp.GetViewRange();
                ElementId     topId = pvr.GetLevelId(PlanViewPlane.TopClipPlane);

                ElementId bottomId = pvr.GetLevelId(PlanViewPlane.ViewDepthPlane);
                if (bottomId.IntegerValue == -4)
                {
                    bottomId = pvr.GetLevelId(PlanViewPlane.BottomClipPlane);
                }
                if (bottomId.IntegerValue == -4)
                {
                    bottomId = pvr.GetLevelId(PlanViewPlane.UnderlayBottom);
                }

                if (topId != ElementId.InvalidElementId)
                {
                    Level top = vp.Document.GetElement(topId) as Level;
                    box.P2 = new XYZ(box.P2.X, box.P2.Y, top.Elevation + pvr.GetOffset(PlanViewPlane.TopClipPlane));
                }
                if (bottomId != ElementId.InvalidElementId)
                {
                    Level bottom = vp.Document.GetElement(bottomId) as Level;
                    box.P1 = new XYZ(box.P1.X, box.P1.Y, bottom.Elevation + pvr.GetOffset(PlanViewPlane.ViewDepthPlane));
                }
            }

            // set the transform
            box.TransformationMatrix = Transform.Identity;
            box.DirectionUp          = vp.UpDirection;
            box.EyePosition          = vp.Origin.Add(vp.ViewDirection.Multiply(10));
            box.DirectionView        = vp.ViewDirection.Negate();
            return(box);
        }
        Stream(ArrayList data, PlanViewRange plvr)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PlanViewRange)));

            data.Add(new Snoop.Data.ElementId("Level Id for CutPlane", plvr.GetLevelId(PlanViewPlane.CutPlane), m_app.ActiveUIDocument.Document));
            data.Add(new Snoop.Data.Double("Offset assiciated with CutPlane", plvr.GetOffset(PlanViewPlane.CutPlane)));
            data.Add(new Snoop.Data.ElementId("Level Id for Bottom Clib Plane", plvr.GetLevelId(PlanViewPlane.BottomClipPlane), m_app.ActiveUIDocument.Document));
            data.Add(new Snoop.Data.Double("Offset assiciated with Bottom Clib Plane", plvr.GetOffset(PlanViewPlane.BottomClipPlane)));
            data.Add(new Snoop.Data.ElementId("Level Id for Top Clib Plane", plvr.GetLevelId(PlanViewPlane.TopClipPlane), m_app.ActiveUIDocument.Document));
            data.Add(new Snoop.Data.Double("Offset assiciated with Top Clib Plane", plvr.GetOffset(PlanViewPlane.TopClipPlane)));
            data.Add(new Snoop.Data.ElementId("Level Id for Underlay Bottom", plvr.GetLevelId(PlanViewPlane.UnderlayBottom), m_app.ActiveUIDocument.Document));
            data.Add(new Snoop.Data.Double("Offset assiciated with Underlay Bottom Plane", plvr.GetOffset(PlanViewPlane.UnderlayBottom)));
            data.Add(new Snoop.Data.ElementId("Level Id for View Depth Plane", plvr.GetLevelId(PlanViewPlane.ViewDepthPlane), m_app.ActiveUIDocument.Document));
            data.Add(new Snoop.Data.Double("Offset assiciated with View Depth Plane", plvr.GetOffset(PlanViewPlane.ViewDepthPlane)));
        }
Beispiel #3
0
        /// <summary>
        /// Gets a representative view generated by the level.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="viewType">The view type.</param>
        /// <param name="level">The level.</param>
        /// <returns>A view associate with the level.</returns>
        /// <remarks>This function will return the first view it finds with a bottom range set to an offset of the generating level.
        /// If no such view is found, but a view based on the generating level exists, that view will be returned.</remarks>
        public static View FindViewByLevel(Document document, ViewType viewType, Level level)
        {
            View possibleView = null;

            ElementFilter            elementFilter = new ElementClassFilter(typeof(View));
            FilteredElementCollector collector     = new FilteredElementCollector(document);

            collector.WherePasses(elementFilter);
            foreach (View view in collector)
            {
                if (view.ViewType != viewType)
                {
                    continue;
                }
                if (view.GenLevel != null && view.GenLevel.Id == level.Id)
                {
                    PlanViewRange viewRange         = (view as ViewPlan).GetViewRange();
                    ElementId     bottomClipPlaneId = viewRange.GetLevelId(PlanViewPlane.BottomClipPlane);
                    if (bottomClipPlaneId != level.Id)
                    {
                        possibleView = view;
                        continue;
                    }
                    return(view);
                }
            }
            return(possibleView);
        }
Beispiel #4
0
        public override void DrillDown()
        {
            if (!HasDrillDown)
            {
                return;
            }

            var sectionDataObjects = new List <SnoopableObjectWrapper>();

            foreach (PlanViewPlane type in Enum.GetValues(typeof(PlanViewPlane)))
            {
                var levelId = _planViewRange.GetLevelId(type);
                if (levelId != null && levelId != Autodesk.Revit.DB.ElementId.InvalidElementId)
                {
                    var level = _document.GetElement(levelId) as Level;
                    sectionDataObjects.Add(new SnoopableObjectWrapper(type.ToString(), level));
                }
                else
                {
                    sectionDataObjects.Add(new SnoopableObjectWrapper(type.ToString(), levelId));
                }
            }

            if (!sectionDataObjects.Any())
            {
                return;
            }

            var form = new Forms.Objects(sectionDataObjects);

            form.ShowDialog();
        }
Beispiel #5
0
        public static Outline Outline(this ViewPlan viewPlan, Transform transform = null)
        {
            if (viewPlan == null)
            {
                return(null);
            }

            PlanViewRange planViewRange = viewPlan.GetViewRange();

            if (planViewRange == null)
            {
                return(null);
            }

            Document document = viewPlan.Document;

            ElementId elementId_Level = null;

            elementId_Level = planViewRange.GetLevelId(PlanViewPlane.TopClipPlane);
            Level  level_TopClipPlane  = document.GetElement(elementId_Level) as Level;
            double offset_TopClipPlane = planViewRange.GetOffset(PlanViewPlane.TopClipPlane);

            elementId_Level = planViewRange.GetLevelId(PlanViewPlane.BottomClipPlane);
            Level  level_BottomClipPlane  = document.GetElement(elementId_Level) as Level;
            double offset_BottomClipPlane = planViewRange.GetOffset(PlanViewPlane.BottomClipPlane);

            BoundingBoxXYZ boundingBoxXYZ = viewPlan.CropBox;

            boundingBoxXYZ.Min = new XYZ(boundingBoxXYZ.Min.X, boundingBoxXYZ.Min.Y, level_BottomClipPlane.Elevation + offset_BottomClipPlane);
            boundingBoxXYZ.Max = new XYZ(boundingBoxXYZ.Max.X, boundingBoxXYZ.Max.Y, level_TopClipPlane.Elevation + offset_TopClipPlane);

            if (transform != null)
            {
                boundingBoxXYZ.Transform = transform.Inverse;
            }

            return(new Outline(boundingBoxXYZ.Min, boundingBoxXYZ.Max));
        }
    public override Form DrillDown()
    {
        if (!HasDrillDown)
        {
            return(null);
        }

        var sectionDataObjects = new List <SnoopableWrapper>();

        foreach (PlanViewPlane type in Enum.GetValues(typeof(PlanViewPlane)))
        {
            var levelId = _planViewRange.GetLevelId(type);
            if (levelId is not null && levelId != ElementId.InvalidElementId)
            {
                var level = _document.GetElement(levelId) as Level;
                sectionDataObjects.Add(new SnoopableWrapper(type.ToString(), level));
            }
      Stream(ArrayList data, PlanViewRange plvr)
      {
          data.Add(new Snoop.Data.ClassSeparator(typeof(PlanViewRange)));

          data.Add(new Snoop.Data.ElementId("Level Id for CutPlane", plvr.GetLevelId(PlanViewPlane.CutPlane), m_app.ActiveUIDocument.Document));
          data.Add(new Snoop.Data.Double("Offset assiciated with CutPlane", plvr.GetOffset(PlanViewPlane.CutPlane)));
          data.Add(new Snoop.Data.ElementId("Level Id for Bottom Clib Plane", plvr.GetLevelId(PlanViewPlane.BottomClipPlane), m_app.ActiveUIDocument.Document));
          data.Add(new Snoop.Data.Double("Offset assiciated with Bottom Clib Plane", plvr.GetOffset(PlanViewPlane.BottomClipPlane)));
          data.Add(new Snoop.Data.ElementId("Level Id for Top Clib Plane", plvr.GetLevelId(PlanViewPlane.TopClipPlane), m_app.ActiveUIDocument.Document));
          data.Add(new Snoop.Data.Double("Offset assiciated with Top Clib Plane", plvr.GetOffset(PlanViewPlane.TopClipPlane)));
          data.Add(new Snoop.Data.ElementId("Level Id for Underlay Bottom", plvr.GetLevelId(PlanViewPlane.UnderlayBottom), m_app.ActiveUIDocument.Document));
          data.Add(new Snoop.Data.Double("Offset assiciated with Underlay Bottom Plane", plvr.GetOffset(PlanViewPlane.UnderlayBottom)));
          data.Add(new Snoop.Data.ElementId("Level Id for View Depth Plane", plvr.GetLevelId(PlanViewPlane.ViewDepthPlane), m_app.ActiveUIDocument.Document));
          data.Add(new Snoop.Data.Double("Offset assiciated with View Depth Plane", plvr.GetOffset(PlanViewPlane.ViewDepthPlane)));
      }
        private void settingCompleted()
        {
            if (!double.TryParse(this.ObstacleSetting.Text, out this.MinimumHeight))
            {
                MessageBox.Show("Enter a valid number for the 'Minimum Height of Visual Obstacles'!\n(Larger than zero)");
                return;
            }
            else if (this.MinimumHeight < 0)
            {
                MessageBox.Show("Enter a valid number for the 'Minimum Height of Visual Obstacles'!\n(Larger than zero)");
                return;
            }
            if (!double.TryParse(this.CurveApproximationLength_.Text, out this.CurveApproximationLength))
            {
                MessageBox.Show("Enter a valid number for 'Curve Approximation Length'!");
                return;
            }
            if (!double.TryParse(this.MinimumCurveLength_.Text, out this.MinimumCurveLength))
            {
                MessageBox.Show("Enter a valid number for 'Minimum Curve Approximation Length'!\n(This length should be smaller than curve approximation length and larger than zero)");
                return;
            }
            else if (this.MinimumCurveLength >= this.CurveApproximationLength || this.MinimumCurveLength <= 0f)
            {
                MessageBox.Show("Enter a valid number for 'Minimum Curve Approximation Length'!\n(This length should be smaller than curve approximation length and larger than zero)");
                return;
            }
            if (this.FloorPlan == null)
            {
                MessageBox.Show("Select a floor plan to continue!");
                return;
            }
            using (Transaction t = new Transaction(this.uidoc.Document, "Update View Range"))
            {
                t.Start();
                try
                {
                    PlanViewRange viewRange          = this.FloorPlan.GetViewRange();
                    ElementId     topClipPlane       = viewRange.GetLevelId(PlanViewPlane.TopClipPlane);
                    double        revitMinimumHeight = UnitConversion.Convert(this.MinimumHeight, this.unitType, Length_Unit_Types.FEET);


                    if (viewRange.GetOffset(PlanViewPlane.TopClipPlane) < revitMinimumHeight)
                    {
                        viewRange.SetOffset(PlanViewPlane.CutPlane, revitMinimumHeight);
                        viewRange.SetOffset(PlanViewPlane.TopClipPlane, revitMinimumHeight);
                    }
                    else
                    {
                        viewRange.SetOffset(PlanViewPlane.CutPlane, revitMinimumHeight);
                    }
                    this.FloorPlan.SetViewRange(viewRange);
                }
                catch (Exception ex)
                {
                    t.Commit();
                    MessageBox.Show(ex.Report());
                }
                t.Commit();
            }
            uidoc.ActiveView    = this.FloorPlan;
            this.floorPlanNames = null;
            this.DialogResult   = true;
            this.Close();
        }
        public static void getCurrentView(Document doc, out ViewItem viewItem)
        {
            viewItem = new ViewItem();
            double topPoint;
            double cutPoint;
            double bottPoint;
            double depthPoint;
            double topToCut;
            double cutToBott;
            double bottToDepth;
            double totalRange;

            double originElevOff;
            double originElev = 0;

            originPosition(doc, out originElev);
            originElevOff = 0 - originElev;

            ViewPlan      vP        = doc.ActiveView as ViewPlan;
            PlanViewRange viewRange = vP.GetViewRange();
            Level         hostLevel = doc.GetElement(vP.LevelId) as Level;

            #region view range info
            //Get top clip data
            Level  topClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.TopClipPlane) as ElementId) as Level;
            double topClipElev   = topClipLevel.Elevation + originElevOff;
            double topClipOffset = viewRange.GetOffset(PlanViewPlane.TopClipPlane);
            topPoint = topClipElev + topClipOffset;

            //Get cut plane
            Level  cutLevel     = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.CutPlane) as ElementId) as Level;
            double cutElevation = cutLevel.Elevation + originElevOff;
            double cutOffset    = viewRange.GetOffset(PlanViewPlane.CutPlane);
            cutPoint = cutElevation + cutOffset;

            //Get bottom clip data
            Level  bottClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.BottomClipPlane) as ElementId) as Level;
            double bottClipElev   = bottClipLevel.Elevation + originElevOff;
            double bottClipOffset = viewRange.GetOffset(PlanViewPlane.BottomClipPlane);
            bottPoint = bottClipElev + bottClipOffset;

            //Get depth clip data
            Level  depthClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.ViewDepthPlane) as ElementId) as Level;
            double depthClipElev   = bottClipLevel.Elevation + originElevOff;
            double depthClipOffset = viewRange.GetOffset(PlanViewPlane.ViewDepthPlane);
            depthPoint = depthClipElev + depthClipOffset;

            topToCut    = topPoint - cutPoint;
            cutToBott   = cutPoint - bottPoint;
            bottToDepth = bottPoint - depthPoint;
            totalRange  = topPoint - depthPoint;
            #endregion

            #region add data to ViewItem.
            viewItem.id              = vP.Id;
            viewItem.name            = vP.Name;
            viewItem.hostLevel       = hostLevel;
            viewItem.topClipLevel    = topClipLevel;
            viewItem.topClipOffset   = topClipOffset;
            viewItem.cutLevel        = cutLevel;
            viewItem.cutOffset       = cutOffset;
            viewItem.bottClipLevel   = bottClipLevel;
            viewItem.bottClipOffset  = bottClipOffset;
            viewItem.depthCLipLevel  = depthClipLevel;
            viewItem.depthClipOffset = depthClipOffset;
            viewItem.topToCut        = topToCut;
            viewItem.cutToBott       = cutToBott;
            viewItem.bottToDepth     = bottToDepth;
            viewItem.totalRange      = totalRange;
            #endregion
        }