/// <summary> /// Create the walls which along and under the path of the selected beams /// </summary> /// <param name="project"> A reference of current document</param> /// <returns>true if there is no error in process; otherwise, false.</returns> Boolean BeginCreate(Autodesk.Revit.DB.Document project) { // Begin to create walls along and under each beam for (int i = 0; i < m_beamCollection.Count; i++) { // Get each selected beam. FamilyInstance m = m_beamCollection[i] as FamilyInstance; if (null == m) { m_errorInformation = "The program should not go here."; return false; } // Get the analytical model of the beam, // the wall will be created using this model line as path. AnalyticalModel model = m.GetAnalyticalModel(); if (null == model) { m_errorInformation = "The beam should have analytical model."; return false; } // Get the level using the beam's reference level Autodesk.Revit.DB.ElementId levelId = m.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId(); m_level = project.get_Element(levelId) as Level; if (null == m_level) { m_errorInformation = "The program should not go here."; return false; } Transaction t = new Transaction(project, Guid.NewGuid().GetHashCode().ToString()); t.Start(); Wall createdWall = project.Create.NewWall(model.GetCurve(), m_selectedWallType, m_level, 10, 0, true, m_isStructural); if (null == createdWall) { m_errorInformation = "Can not create the walls"; return false; } // Modify some parameters of the created wall to make it look better. Double offset = model.GetCurve().get_EndPoint(0).Z - m_level.Elevation; createdWall.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).Set(levelId); createdWall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).Set(offset - 3000 / 304.8); createdWall.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE).Set(levelId); t.Commit(); } return true; }