/// <summary> /// Batch creation of Rooms /// </summary> /// <returns>If batch creation succeeds, return true; otherwise, return false</returns> private bool CreateRooms() { try { if (null == m_level) { return(false); } //Try to get Phase used to create Rooms Phase phase = (from elem in new FilteredElementCollector(m_doc).OfClass(typeof(Phase)).ToElements() select elem).First() as Phase; if (null == phase) { return(false); } // Create AreaCreateDatas for Rooms' batch creation List <RoomCreationData> roomCreationDatas = new List <RoomCreationData>(); for (int i = 1; i < 6; i++) { Autodesk.Revit.DB.UV point = new Autodesk.Revit.DB.UV(i * 10, 0); Autodesk.Revit.DB.UV tagPoint = new Autodesk.Revit.DB.UV(i * 10, 0); RoomCreationData roomCreationData = new RoomCreationData(m_level, point); if (null != roomCreationData) { roomCreationData.TagPoint = tagPoint; roomCreationDatas.Add(roomCreationData); } } // Create Rooms if (0 == roomCreationDatas.Count) { return(false); } m_doc.Create.NewRooms(roomCreationDatas); } catch (Exception) { return(false); } return(true); }
/// <summary> /// Batch creation of Rooms /// </summary> /// <returns>If batch creation succeeds, return true; otherwise, return false</returns> private bool CreateRooms() { try { if (null == m_level) { return false; } //Try to get Phase used to create Rooms Phase phase = (from elem in new FilteredElementCollector(m_doc).OfClass(typeof(Phase)).ToElements() select elem).First() as Phase; if (null == phase) { return false; } // Create AreaCreateDatas for Rooms' batch creation List<RoomCreationData> roomCreationDatas = new List<RoomCreationData>(); for (int i = 1; i < 6; i++) { Autodesk.Revit.DB.UV point = new Autodesk.Revit.DB.UV (i * 10, 0); Autodesk.Revit.DB.UV tagPoint = new Autodesk.Revit.DB.UV (i * 10, 0); RoomCreationData roomCreationData = new RoomCreationData(m_level, point); if (null != roomCreationData) { roomCreationData.TagPoint = tagPoint; roomCreationDatas.Add(roomCreationData); } } // Create Rooms if (0 == roomCreationDatas.Count) { return false; } m_doc.Create.NewRooms(roomCreationDatas); } catch (Exception) { return false; } return true; }