void ReconstructBuildingPadByOutline ( DB.Document doc, ref DB.Architecture.BuildingPad element, IList <Rhino.Geometry.Curve> boundaries, Optional <DB.BuildingPadType> type, Optional <DB.Level> level ) { ChangeElementType(ref element, type); var scaleFactor = 1.0 / Revit.ModelUnits; boundaries = boundaries.Select(x => x.ChangeUnits(scaleFactor)).ToArray(); var boundaryBBox = Rhino.Geometry.BoundingBox.Empty; foreach (var boundary in boundaries) { boundaryBBox.Union(boundary.GetBoundingBox(true)); } var curveLoops = boundaries.Select(region => DB.CurveLoop.Create(region.ToHostMultiple().SelectMany(x => x.ToBoundedCurves()).ToList())); SolveOptionalLevel(ref level, doc, boundaryBBox.Min.Z); if (element is DB.Architecture.BuildingPad buildingPad) { element.get_Parameter(DB.BuiltInParameter.LEVEL_PARAM).Set(level.Value.Id); buildingPad.SetBoundary(curveLoops.ToList()); } else { SolveOptionalType(ref type, doc, DB.ElementTypeGroup.BuildingPadType, (document, param) => DB.BuildingPadType.CreateDefault(document), nameof(type)); var newPad = DB.Architecture.BuildingPad.Create ( doc, type.Value.Id, level.Value.Id, curveLoops.ToList() ); ReplaceElement(ref element, newPad, ParametersMask); } element?.get_Parameter(DB.BuiltInParameter.BUILDINGPAD_HEIGHTABOVELEVEL_PARAM).Set(boundaryBBox.Min.Z - level.Value.Elevation); }
void ReconstructBuildingPadByOutline ( DB.Document doc, ref DB.Architecture.BuildingPad element, IList <Rhino.Geometry.Curve> boundaries, Optional <DB.BuildingPadType> type, Optional <DB.Level> level ) { ChangeElementType(ref element, type); SolveOptionalLevel(doc, boundaries, ref level, out var boundaryBBox); var curveLoops = boundaries.ConvertAll(GeometryEncoder.ToCurveLoop); if (element is DB.Architecture.BuildingPad buildingPad) { element.get_Parameter(DB.BuiltInParameter.LEVEL_PARAM).Set(level.Value.Id); buildingPad.SetBoundary(curveLoops); } else { SolveOptionalType(ref type, doc, DB.ElementTypeGroup.BuildingPadType, (document, param) => DB.BuildingPadType.CreateDefault(document), nameof(type)); var newPad = DB.Architecture.BuildingPad.Create ( doc, type.Value.Id, level.Value.Id, curveLoops ); ReplaceElement(ref element, newPad, ParametersMask); } element?.get_Parameter(DB.BuiltInParameter.BUILDINGPAD_HEIGHTABOVELEVEL_PARAM).Set(boundaryBBox.Min.Z / Revit.ModelUnits - level.Value.GetHeight()); }