Ejemplo n.º 1
0
        private void RefreshViewsList(ListBox listBox, DB.ViewFamily viewFamily)
        {
            var doc = Revit.ActiveUIDocument.Document;

            listBox.SelectedIndexChanged -= ListBox_SelectedIndexChanged;
            listBox.Items.Clear();

            using (var collector = new DB.FilteredElementCollector(doc))
            {
                var views = collector.
                            OfClass(typeof(DB.View)).
                            Cast <DB.View>().
                            Where(x => !x.IsTemplate).
                            Where(x => viewFamily == DB.ViewFamily.Invalid || x.Document.GetElement <DB.ViewFamilyType>(x.GetTypeId())?.ViewFamily == viewFamily);

                listBox.DisplayMember = "DisplayName";
                foreach (var view in views)
                {
                    listBox.Items.Add(new Types.View(view));
                }
            }

            listBox.SelectedIndex         = listBox.Items.OfType <Types.View>().IndexOf(Current, 0).FirstOr(-1);
            listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
        }
Ejemplo n.º 2
0
        protected static ViewPlan CreatePlanView(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.ViewFamily planType)
        {
            var viewFam = DocumentManager.Instance.ElementsOfType <ViewFamilyType>()
                          .FirstOrDefault(x => x.ViewFamily == planType);

            if (viewFam == null)
            {
                throw new Exception("There is no such ViewFamily in the document");
            }

            return(ViewPlan.Create(Document, viewFam.Id, level.Id));;
        }