/// <summary> /// add more levels so that level number can meet floor number /// </summary> public void UpdateLevels() { double baseElevation = m_levels.Values[m_levels.Count - 1].Elevation; Autodesk.Revit.Creation.Document createDoc = m_commandData.Application.ActiveUIDocument.Document.Create; Autodesk.Revit.DB.Document m_Doc = m_commandData.Application.ActiveUIDocument.Document; FilteredElementCollector collector = new FilteredElementCollector(m_Doc); IList <Element> viewFamilyTypes = collector.OfClass(typeof(ViewFamilyType)).ToElements(); ElementId floorPlanId = new ElementId(-1); foreach (Element e in viewFamilyTypes) { ViewFamilyType v = e as ViewFamilyType; if (v != null && v.ViewFamily == ViewFamily.FloorPlan) { floorPlanId = e.Id; break; } } int newLevelSize = (m_floorNumber + 1) - m_levels.Count; if (newLevelSize == 0) { return; } for (int ii = 0; ii < newLevelSize; ii++) { double elevation = baseElevation + m_levelHeight * (ii + 1); Level newLevel = createDoc.NewLevel(elevation); //createDoc.NewViewPlan(newLevel.Name, newLevel, Autodesk.Revit.DB.ViewPlanType.FloorPlan); ViewPlan viewPlan = ViewPlan.Create(m_Doc, floorPlanId, newLevel.Id); viewPlan.Name = newLevel.Name; m_levels.Add(elevation, newLevel); } m_originalLevelSize = m_levels.Count; }
/// <summary> /// add more levels so that level number can meet floor number /// </summary> public void UpdateLevels() { double baseElevation = m_levels.Values[m_levels.Count - 1].Elevation; Autodesk.Revit.Creation.Document createDoc = m_commandData.Application.ActiveUIDocument.Document.Create; int newLevelSize = (m_floorNumber + 1) - m_levels.Count; if (newLevelSize == 0) { return; } for (int ii = 0; ii < newLevelSize; ii++) { double elevation = baseElevation + m_levelHeight * (ii + 1); Level newLevel = createDoc.NewLevel(elevation); createDoc.NewViewPlan(newLevel.Name, newLevel, Autodesk.Revit.DB.ViewPlanType.FloorPlan); m_levels.Add(elevation, newLevel); } m_originalLevelSize = m_levels.Count; }