public Opening(IWall myWall, IDimension dimensions, ILocation location, OpeningType openingType) { // WallOrSlap = myWall; Dimensions = dimensions; Location = location; OpeningType = openingType; }
public static IOpening ToSAM_Opening(this EnergyAnalysisOpening energyAnalysisOpening, ConvertSettings convertSettings) { if (energyAnalysisOpening == null) { return(null); } IOpening result = convertSettings?.GetObject <IOpening>(energyAnalysisOpening.Id); if (result != null) { return(result); } Polygon3D polygon3D = energyAnalysisOpening.GetPolyloop().ToSAM(); if (polygon3D == null) { return(null); } FamilyInstance familyInstance = Core.Revit.Query.Element(energyAnalysisOpening) as FamilyInstance; if (familyInstance == null) { return(null); } if (Core.Revit.Query.Simplified(familyInstance)) { result = Core.Revit.Query.IJSAMObjects <IOpening>(familyInstance)?.FirstOrDefault(); if (result != null) { return(result); } } OpeningType openingType = ToSAM_OpeningType(familyInstance.Symbol, convertSettings); Point3D point3D_Location = Geometry.Revit.Query.LocationPoint3D(familyInstance); if (point3D_Location == null) { return(null); } Face3D face3D = new Face3D(Geometry.Spatial.Create.IClosedPlanar3D(polygon3D, point3D_Location)); if (face3D == null) { return(null); } result = Analytical.Create.Opening(openingType, face3D); result.UpdateParameterSets(familyInstance); convertSettings?.Add(energyAnalysisOpening.Id, result); return(result); }
public static string UniqueName(this OpeningType openingType, bool reverse = true) { if (openingType == null) { return(null); } return(UniqueName((Core.SAMType)openingType, reverse)); }
public void ShotEdge(Vector3 point, OpeningType type, Wall w) { if (state == FinalState(type)) { SetEdge(point, w); CreateOpening(); } else { this.type = type; SetEdge(point, w); } }
public static OpeningType FixBuildingElementType(this OpeningType bHoMBuildingElementType, TBD.buildingElement tbdBuildingElement, TBD.zoneSurface tbdZoneSurface) { if (bHoMBuildingElementType == OpeningType.Frame) { if (tbdBuildingElement.name.Contains("-frame")) { if (tbdZoneSurface.inclination == 0) { bHoMBuildingElementType = OpeningType.RooflightWithFrame; } else { bHoMBuildingElementType = OpeningType.WindowWithFrame; } } } return(bHoMBuildingElementType); }
public frmOpeningType(OpeningType value) { InitializeComponent(); _Opening = value; tbName.Text = _Opening.Name; tbPurpose.Text = _Opening.Purpose; nudHeight.Value = _Opening.Height; nudWidth.Value = _Opening.Width; nudBottom.Value = _Opening.Bottom; cbAddEdgeLeft.Checked = _Opening.AddEdgeLeft; cbAddEdgeRight.Checked = _Opening.AddEdgeRight; cbAddEdgeTop.Checked = _Opening.AddEdgeTop; cbAddEdgeBottom.Checked = _Opening.AddEdgeBottom; cbMoveVert.Checked = _Opening.MoveVert; nudQuantVertLeft.Value = _Opening.QuantVertLeft; nudQuantVertRight.Value = _Opening.QuantVertRight; nudQuantInclined.Value = _Opening.QuantInclined; cbIncTopLeft.Checked = _Opening.AddIncTopLeft; cbIncTopRight.Checked = _Opening.AddIncTopRight; cbIncBottomLeft.Checked = _Opening.AddIncBottomLeft; cbIncBottomRight.Checked = _Opening.AddIncBottomRight; }
private void tsbNew_Click(object sender, EventArgs e) { ProgrammSettings.IsDataChanged = true; switch (_formType) // { case "Buildings": { break; } case "Levels": { Level level = new Level((Building)_parentObject); NewItemFromLevel(level); break; } //Add new Opening case "OpeningPlacings": { OpeningPlacing openingPlacing = new OpeningPlacing((Wall)_parentObject); NewItemFromOpeningPlacing(openingPlacing); break; } //Add new OpeningType case "OpeningTypes": { OpeningType openingType = new OpeningType((Building)_parentObject); NewItemFromOpeningType(openingType); break; } case ObjColumnBaseParts: { SteelBasePart basePart = new SteelBasePart((SteelColumnBase)_parentObject); NewItemFromColumnBasePart(basePart); break; } case ObjBarForses: { BarLoadSet columnLoadSet = new BarLoadSet((SteelColumnBase)_parentObject); NewItemFromColumnLoadSet(columnLoadSet); break; } case ObjSteelColumnBases: { SteelColumnBase steelColumnBase = new SteelColumnBase((Level)_parentObject); NewItemFromSteelColumnBase(steelColumnBase); #region Вложенные объекты по умолчанию //Нагрузка BarLoadSet columnLoadSet = new BarLoadSet(steelColumnBase); columnLoadSet.LoadSet.Name = "Постоянная"; //Участок №1 SteelBasePart basePart1 = new SteelBasePart(steelColumnBase); basePart1.Name = "1"; basePart1.Width = 0.290; basePart1.Length = 0.200; basePart1.Center[0] = 0.155; basePart1.Center[1] = 0.350; basePart1.FixLeft = true; basePart1.FixRight = false; basePart1.FixTop = false; basePart1.FixBottom = true; basePart1.AddSymmetricX = true; basePart1.AddSymmetricY = true; //Участок №2 SteelBasePart basePart2 = new SteelBasePart(steelColumnBase); basePart2.Name = "2"; basePart2.Width = 0.290; basePart2.Length = 0.480; basePart2.Center[0] = 0.155; basePart2.Center[1] = 0; basePart2.FixLeft = true; basePart2.FixRight = false; basePart2.FixTop = true; basePart2.FixBottom = true; basePart2.AddSymmetricX = false; basePart2.AddSymmetricY = true; #endregion break; } case "Walls": { Wall wall = new Wall((Level)_parentObject); NewItemFromWall(wall); break; } case "WallTypes": { WallType wallType = new WallType((Building)_parentObject); NewItemFromWallType(wallType); break; } } }
public static IOpening ToSAM_Opening(this FamilyInstance familyInstance, ConvertSettings convertSettings) { if (familyInstance == null) { return(null); } IOpening result = convertSettings?.GetObject <IOpening>(familyInstance.Id); if (result != null) { return(result); } if (Core.Revit.Query.Simplified(familyInstance)) { result = Core.Revit.Query.IJSAMObjects <IOpening>(familyInstance)?.FirstOrDefault(); if (result != null) { convertSettings?.Add(familyInstance.Id, result); return(result); } } Point3D point3D_Location = Geometry.Revit.Query.LocationPoint3D(familyInstance); if (point3D_Location == null) { List <Solid> solids = Core.Revit.Query.Solids(familyInstance, new Options()); solids?.RemoveAll(x => x.Volume == 0); if (solids == null || solids.Count == 0) { return(null); } if (solids.Count > 1) { solids.Sort((x, y) => y.Volume.CompareTo(x.Volume)); } point3D_Location = solids[0].ComputeCentroid()?.ToSAM(); } if (point3D_Location == null) { return(null); } OpeningType openingType = ToSAM_OpeningType(familyInstance.Symbol, convertSettings); if (openingType == null) { return(null); } BuiltInCategory builtInCategory_Host = BuiltInCategory.INVALID; HostObject hostObject = familyInstance.Host as HostObject; if (hostObject != null) { builtInCategory_Host = (BuiltInCategory)hostObject.Category.Id.IntegerValue; } Vector3D axisX = null; Vector3D normal = null; Vector3D axisY = null; if (builtInCategory_Host == BuiltInCategory.OST_Roofs) { axisX = familyInstance.HandOrientation.ToSAM_Vector3D(false); axisY = familyInstance.FacingOrientation.ToSAM_Vector3D(false); normal = Geometry.Spatial.Query.AxisY(axisY, axisX); } else { axisX = familyInstance.HandOrientation.ToSAM_Vector3D(false); normal = familyInstance.FacingOrientation.ToSAM_Vector3D(false); axisY = Geometry.Spatial.Query.AxisY(normal, axisX); } Geometry.Spatial.Plane plane = Geometry.Spatial.Create.Plane(point3D_Location, axisX, axisY); if (!plane.Normal.SameHalf(normal)) { plane.FlipZ(false); } List <Face3D> face3Ds = Geometry.Revit.Convert.ToSAM_Geometries <Face3D>(familyInstance); if (face3Ds == null || face3Ds.Count == 0) { return(null); } List <Point2D> point2Ds = new List <Point2D>(); foreach (Face3D face3D_Temp in face3Ds) { IClosedPlanar3D closedPlanar3D = face3D_Temp.GetExternalEdge3D(); if (closedPlanar3D is ICurvable3D) { List <ICurve3D> curve3Ds = ((ICurvable3D)closedPlanar3D).GetCurves(); foreach (ICurve3D curve3D in curve3Ds) { ICurve3D curve3D_Temp = plane.Project(curve3D); point2Ds.Add(plane.Convert(curve3D_Temp.GetStart())); } } } if (point2Ds == null || point2Ds.Count == 0) { return(null); } Rectangle2D rectangle2D = Geometry.Planar.Create.Rectangle2D(point2Ds); result = Analytical.Create.Opening(openingType, new Face3D(plane, rectangle2D)); result.UpdateParameterSets(familyInstance); convertSettings?.Add(familyInstance.Id, result); return(result); }
private static OpeningShotState FinalState(OpeningType opType) { return(opType == OpeningType.Door ? OpeningShotState.Right : OpeningShotState.Bottom); }
public static List <IAnalyticalObject> ToSAM_AnalyticalObject(this Element element, ConvertSettings convertSettings) { List <IAnalyticalObject> result = null; if (element is WallSweep) { List <IPartition> partitions = ToSAM_Partitions((WallSweep)element, convertSettings); if (partitions != null) { result = partitions.ConvertAll(x => x as IAnalyticalObject); } } else if (element is HostObject) { List <IPartition> partitions = ToSAM_Partitions((HostObject)element, convertSettings); if (partitions != null) { result = partitions.ConvertAll(x => x as IAnalyticalObject); } } else if (element is HostObjAttributes) { HostPartitionType hostPartitionType = ToSAM_HostPartitionType((HostObjAttributes)element, convertSettings); if (hostPartitionType != null) { result = new List <IAnalyticalObject>() { hostPartitionType } } ; } else if (element is SpatialElement) { Space space = ToSAM((SpatialElement)element, convertSettings); if (space != null) { result = new List <IAnalyticalObject>() { space } } ; } else if (element is FamilyInstance) { FamilyInstance familyInstance = (FamilyInstance)element; if (element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows || element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Doors) { IOpening opening = ToSAM_Opening(familyInstance, convertSettings); if (opening != null) { result = new List <IAnalyticalObject>() { opening } } ; } else { //result = familyInstance.ToSAM_Panels(convertSettings); } } else if (element is FamilySymbol) { if (element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows || element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Doors) { OpeningType openingType = ToSAM_OpeningType((FamilySymbol)element, convertSettings); if (openingType != null) { result = new List <IAnalyticalObject>() { openingType } } ; } } else if (element is ModelCurve) { //if (element.Category != null && (element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_MEPSpaceSeparationLines || element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_RoomSeparationLines)) //{ // List<Panel> panels = ToSAM_Panels((ModelCurve)element, convertSettings); // if (panels != null) // result = panels.ConvertAll(x => x as Core.SAMObject); //} } return(result); }
public static bool AssignOpeningTypes(this TBD.Building building, TBD.buildingElement buildingElement, IEnumerable <TBD.dayType> dayTypes, OpeningType openingType) { if (building == null || buildingElement == null || openingType == null || dayTypes == null) { return(false); } TBD.ApertureType apertureType_Day = null; string function; function = null; if (openingType.TryGetValue("SAM_ApertureFunctionDay", out function, true) && !string.IsNullOrWhiteSpace(function)) { apertureType_Day = building.AddApertureType(null); apertureType_Day.name = buildingElement.name + "_Day"; foreach (TBD.dayType aDayType in dayTypes) { apertureType_Day.SetDayType(aDayType, true); } int sheltered; if (openingType.TryGetValue("SAM_ApertureShelteredDay", out sheltered, true)) { apertureType_Day.sheltered = sheltered; } else { apertureType_Day.sheltered = 0; } string description_ApertureType; if (openingType.TryGetValue("SAM_ApertureDescriptionDay", out description_ApertureType, true)) { apertureType_Day.description = description_ApertureType; } TBD.profile profile = apertureType_Day.GetProfile(); profile.type = TBD.ProfileTypes.ticFunctionProfile; profile.function = function; double factor; if (openingType.TryGetValue("SAM_ApertureOpeningProportionDay", out factor, true)) { profile.factor = (float)factor; } double setbackValue; if (openingType.TryGetValue("SAM_ApertureOpeningProportionDaySetBack", out setbackValue, true)) { profile.setbackValue = (float)setbackValue; } string description_Profile; if (openingType.TryGetValue("SAM_ApertureProfileDescriptionDay", out description_Profile, true)) { profile.description = description_Profile; } string scheduleValues; if (openingType.TryGetValue("SAM_ApertureScheduleDay", out scheduleValues, true)) { string name_Schedule = string.Format("{0}_{1}", apertureType_Day.name, "APSCHED"); List <int> values = scheduleValues.Ints(); TBD.schedule schedule = Create.Schedule(building, name_Schedule, values); if (schedule != null) { profile.schedule = schedule; } } } TBD.ApertureType apertureType_Night = null; function = null; if (openingType.TryGetValue("SAM_ApertureFunctionNight", out function, true) && !string.IsNullOrWhiteSpace(function)) { apertureType_Day = building.AddApertureType(null); apertureType_Day.name = buildingElement.name + "_Night"; foreach (TBD.dayType aDayType in dayTypes) { apertureType_Day.SetDayType(aDayType, true); } int sheltered; if (openingType.TryGetValue("SAM_ApertureShelteredNight", out sheltered, true)) { apertureType_Day.sheltered = sheltered; } else { apertureType_Day.sheltered = 0; } string description_ApertureType; if (openingType.TryGetValue("SAM_ApertureDescriptionNight", out description_ApertureType, true)) { apertureType_Day.description = description_ApertureType; } TBD.profile profile = apertureType_Day.GetProfile(); profile.type = TBD.ProfileTypes.ticFunctionProfile; profile.function = function; double factor; if (openingType.TryGetValue("SAM_ApertureOpeningProportionNight", out factor, true)) { profile.factor = (float)factor; } double setbackValue; if (openingType.TryGetValue("SAM_ApertureOpeningProportionNightSetBack", out setbackValue, true)) { profile.setbackValue = (float)setbackValue; } string description_Profile; if (openingType.TryGetValue("SAM_ApertureProfileDescriptionNight", out description_Profile, true)) { profile.description = description_Profile; } string scheduleValues; if (openingType.TryGetValue("SAM_ApertureScheduleNight", out scheduleValues, true)) { string name_Schedule = string.Format("{0}_{1}", apertureType_Day.name, "APSCHED"); List <int> values = scheduleValues.Ints(); TBD.schedule schedule = Create.Schedule(building, name_Schedule, values); if (schedule != null) { profile.schedule = schedule; } } } if (apertureType_Day != null) { buildingElement.AssignApertureType(apertureType_Day); } if (apertureType_Night != null) { buildingElement.AssignApertureType(apertureType_Night); } return(true); }
/// <summary> /// Creates a new instance of a Opening object, and initializes it with the specified property values. /// </summary> /// <param name="activity"></param> /// <param name="name"></param> /// <param name="minParticipants"></param> /// <param name="maxParticipants"></param> /// <param name="type"></param> /// <param name="process"></param> public Opening(Activity activity, string name, int minParticipants, int maxParticipants, OpeningType type, ApplicationProcess process, CriteriaRule criteriaRule = CriteriaRule.Participate, OpeningState state = OpeningState.Published) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentException($"Argument 'name' cannot be null, empty or whitespace."); } if (minParticipants <= 0) { throw new ArgumentException($"Argument 'minParticipants' must be greater than 0."); } if (maxParticipants < minParticipants) { throw new ArgumentException($"Argument 'maxParticipants' must be greater than or equal to 'minParticipants'."); } this.ActivityId = activity?.Id ?? throw new ArgumentNullException(nameof(activity)); this.Activity = activity; this.Name = name; this.MinParticipants = minParticipants; this.MaxParticipants = maxParticipants; this.OpeningType = type; this.ApplicationProcess = process; this.Key = Guid.NewGuid(); this.State = state; this.CriteriaRule = criteriaRule; }
public static OpeningType ToSAM_OpeningType(this FamilySymbol familySymbol, ConvertSettings convertSettings) { if (familySymbol == null) { return(null); } OpeningType result = convertSettings?.GetObject <OpeningType>(familySymbol.Id); if (result != null) { return(result); } string name = familySymbol.Name; switch ((BuiltInCategory)familySymbol.Category.Id.IntegerValue) { case BuiltInCategory.OST_Windows: case BuiltInCategory.OST_CurtainWallPanels: result = new WindowType(name); break; case BuiltInCategory.OST_Doors: result = new DoorType(name); break; } if (result == null) { return(null); } Dictionary <ElementId, List <Shell> > materialElementIdsDictionary = Geometry.Revit.Query.MaterialElementIdsDictionary(familySymbol); if (materialElementIdsDictionary != null && materialElementIdsDictionary.Count != 0) { Document document = familySymbol.Document; Material material_Transparent = null; double volume_Transparent = double.MinValue; double thickness_Transparent = 0; Material material_Opaque = null; double volume_Opaque = double.MinValue; double thickness_Opaque = 0; foreach (KeyValuePair <ElementId, List <Shell> > keyValuePair in materialElementIdsDictionary) { Material material = document.GetElement(keyValuePair.Key) as Material; if (material == null) { continue; } double volume = keyValuePair.Value.ConvertAll(x => x.Volume()).Sum(); if (Core.Revit.Query.IsTransparent(material)) { if (volume_Transparent < volume) { volume_Transparent = volume; material_Transparent = material; thickness_Transparent = Geometry.Spatial.Query.MinDimension(keyValuePair.Value.ConvertAll(x => x.GetBoundingBox())); } } else { if (volume_Opaque < volume) { volume_Opaque = volume; material_Opaque = material; thickness_Opaque = Geometry.Spatial.Query.MinDimension(keyValuePair.Value.ConvertAll(x => x.GetBoundingBox())); } } } if (material_Transparent != null) { List <Architectural.MaterialLayer> materialLayers = new List <Architectural.MaterialLayer>(); materialLayers.Add(new Architectural.MaterialLayer(material_Transparent.Name, thickness_Transparent)); result.PaneMaterialLayers = materialLayers; } if (material_Opaque != null) { List <Architectural.MaterialLayer> materialLayers = new List <Architectural.MaterialLayer>(); materialLayers.Add(new Architectural.MaterialLayer(material_Opaque.Name, thickness_Opaque)); result.FrameMaterialLayers = materialLayers; } } result.UpdateParameterSets(familySymbol); convertSettings?.Add(familySymbol.Id, result); return(result); }