/// <summary> /// Create a new footprint roof. /// </summary> private void createFootPrintRoof() { try { if (m_roofsManager.FootPrint.Size != 0) { Autodesk.Revit.DB.Level level = levelsComboBox.SelectedItem as Autodesk.Revit.DB.Level; Autodesk.Revit.DB.RoofType roofType = roofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType; if (level != null && roofType != null) { Autodesk.Revit.DB.FootPrintRoof roof = m_roofsManager.CreateFootPrintRoof(level, roofType); if (roof == null) { TaskDialog.Show("Revit", "Invalid footprint2"); } else { this.footPrintRoofsListView.Items.Add(new RoofItem(roof)); this.footPrintRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } } } else { TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit."); } } catch (Exception ex) { TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops."); } }
void ReconstructRoofByOutline ( DB.Document doc, ref DB.FootPrintRoof element, Rhino.Geometry.Curve boundary, Optional <DB.RoofType> type, Optional <DB.Level> level ) { var scaleFactor = 1.0 / Revit.ModelUnits; if ( ((boundary = boundary.ChangeUnits(scaleFactor)) is null) || boundary.IsShort(Revit.ShortCurveTolerance) || !boundary.IsClosed || !boundary.TryGetPlane(out var boundaryPlane, Revit.VertexTolerance) || boundaryPlane.ZAxis.IsParallelTo(Rhino.Geometry.Vector3d.ZAxis) == 0 ) { ThrowArgumentException(nameof(boundary), "Boundary should be an horizontal planar closed curve."); } SolveOptionalType(ref type, doc, DB.ElementTypeGroup.RoofType, nameof(type)); double minZ = boundary.GetBoundingBox(true).Min.Z; SolveOptionalLevel(ref level, doc, minZ); var parametersMask = new DB.BuiltInParameter[] { DB.BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, DB.BuiltInParameter.ELEM_FAMILY_PARAM, DB.BuiltInParameter.ELEM_TYPE_PARAM, DB.BuiltInParameter.LEVEL_PARAM, DB.BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM }; using (var curveArray = boundary.ToHostMultiple().ToCurveArray()) { var footPrintToModelCurvesMapping = new DB.ModelCurveArray(); ReplaceElement(ref element, doc.Create.NewFootPrintRoof(curveArray, level.Value, type.Value, out footPrintToModelCurvesMapping), parametersMask); } if (element != null) { element.get_Parameter(DB.BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM).Set(minZ - level.Value.Elevation); } }
void ReconstructRoofByOutline ( DB.Document doc, ref DB.FootPrintRoof element, Rhino.Geometry.Curve boundary, Optional <DB.RoofType> type, Optional <DB.Level> level ) { if ( boundary.IsShort(Revit.ShortCurveTolerance * Revit.ModelUnits) || !boundary.IsClosed || !boundary.TryGetPlane(out var boundaryPlane, Revit.VertexTolerance * Revit.ModelUnits) || boundaryPlane.ZAxis.IsParallelTo(Rhino.Geometry.Vector3d.ZAxis) == 0 ) { ThrowArgumentException(nameof(boundary), "Boundary should be an horizontal planar closed curve."); } SolveOptionalType(ref type, doc, DB.ElementTypeGroup.RoofType, nameof(type)); SolveOptionalLevel(doc, boundary, ref level, out var bbox); var parametersMask = new DB.BuiltInParameter[] { DB.BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, DB.BuiltInParameter.ELEM_FAMILY_PARAM, DB.BuiltInParameter.ELEM_TYPE_PARAM, DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM, DB.BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM }; using (var curveArray = boundary.ToCurveArray()) { var footPrintToModelCurvesMapping = new DB.ModelCurveArray(); ReplaceElement(ref element, doc.Create.NewFootPrintRoof(curveArray, level.Value, type.Value, out footPrintToModelCurvesMapping), parametersMask); } if (element != null) { element.get_Parameter(DB.BuiltInParameter.ROOF_LEVEL_OFFSET_PARAM).Set(bbox.Min.Z / Revit.ModelUnits - level.Value.GetHeight()); } }