public static HoneybeeSchema.Door ToLadybugTools_Door(this Aperture aperture, MaterialLibrary materialLibrary = null, int index = -1, int index_Adjacent = -1, string adjacentPanelUniqueName = null, string adjacentSpaceUniqueName = null) { if (aperture == null) { return(null); } ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction == null) { return(null); } MaterialType materialType = apertureConstruction.PaneConstructionLayers.MaterialType(materialLibrary); if (aperture.ApertureType != ApertureType.Door) { //Opaque Windows to be replaced by Doors if (materialType != MaterialType.Opaque) { return(null); } } PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D; if (planarBoundary3D == null) { return(null); } HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = new Outdoors(); Face3D face3D = planarBoundary3D.ToLadybugTools(); if (!string.IsNullOrEmpty(adjacentPanelUniqueName) && !string.IsNullOrEmpty(adjacentSpaceUniqueName)) { List <string> uniqueNames = new List <string>(); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(aperture, index_Adjacent)); uniqueNames.Add(adjacentPanelUniqueName); uniqueNames.Add(adjacentSpaceUniqueName); anyOf = new Surface(uniqueNames); } DoorEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(Query.UniqueName(apertureConstruction, !(index_Adjacent != -1 && index <= index_Adjacent))); HoneybeeSchema.Door door = new HoneybeeSchema.Door( identifier: Core.LadybugTools.Query.UniqueName(aperture, index), geometry: face3D, boundaryCondition: anyOf, properties: new DoorPropertiesAbridged(apertureEnergyPropertiesAbridged), displayName: aperture.Name); door.IsGlass = materialType == MaterialType.Transparent; return(door); }
public void updateDoorPanel(DoorEntity hbObjEntity) { var apt = hbObjEntity.HBObject; var layout = new DynamicLayout { }; layout.Spacing = new Size(5, 5); layout.Padding = new Padding(10); layout.DefaultSpacing = new Size(2, 2); layout.AddSeparateRow(new Label { Text = $"ID: {apt.Name}" }); layout.AddSeparateRow(new Label { Text = "Name:" }); var nameTBox = new TextBox() { }; apt.DisplayName = apt.DisplayName ?? string.Empty; nameTBox.TextBinding.Bind(apt, m => m.DisplayName); layout.AddSeparateRow(nameTBox); layout.AddSeparateRow(new Label { Text = "Glass:" }); var operableCBox = new CheckBox(); operableCBox.CheckedBinding.Bind(apt, v => v.IsGlass); layout.AddSeparateRow(operableCBox); layout.AddSeparateRow(new Label { Text = "Boundary Condition: (WIP)" }); var bcTBox = new TextBox() { }; bcTBox.Enabled = false; bcTBox.TextBinding.Bind(apt, m => m.BoundaryCondition.Obj.GetType().Name); layout.AddSeparateRow(bcTBox); layout.AddSeparateRow(new Label { Text = "Properties:" }); var faceRadPropBtn = new Button { Text = "Radiance Properties (WIP)" }; faceRadPropBtn.Click += (s, e) => Dialogs.ShowMessage("Work in progress", "Honeybee"); layout.AddSeparateRow(faceRadPropBtn); var faceEngPropBtn = new Button { Text = "Energy Properties" }; faceEngPropBtn.Click += (s, e) => PropBtn_Click(hbObjEntity); layout.AddSeparateRow(faceEngPropBtn); layout.AddSeparateRow(new Label { Text = "IndoorShades:" }); var inShadesListBox = new ListBox(); inShadesListBox.Height = 50; var inShds = apt.IndoorShades; if (inShds != null) { var idShds = inShds.Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); inShadesListBox.Items.AddRange(idShds); } layout.AddSeparateRow(inShadesListBox); layout.AddSeparateRow(new Label { Text = "OutdoorShades:" }); var outShadesListBox = new ListBox(); outShadesListBox.Height = 50; var outShds = apt.OutdoorShades; if (outShds != null) { var outShdItems = outShds.Select(_ => new ListItem() { Text = _.DisplayName ?? _.Name, Tag = _ }); outShadesListBox.Items.AddRange(outShdItems); } layout.AddSeparateRow(outShadesListBox); layout.Add(null); var data_button = new Button { Text = "Honeybee Data" }; data_button.Click += (sender, e) => Dialogs.ShowEditBox("Honeybee Data", "Honeybee Data can be shared across all platforms.", apt.ToJson(), true, out string outJson); layout.AddSeparateRow(data_button, null); this.Content = layout; //layout.up void PropBtn_Click(Entities.DoorEntity ent) { var energyProp = ent.HBObject.Properties.Energy ?? new DoorEnergyPropertiesAbridged(); energyProp = DoorEnergyPropertiesAbridged.FromJson(energyProp.ToJson()); var dialog = new UI.Dialog_DoorEnergyProperty(energyProp); dialog.RestorePosition(); var dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow); dialog.SavePosition(); if (dialog_rc != null) { //replace brep in order to add an undo history var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set Honeybee door energy properties"); var dup = ent.HostObjRef.Brep().DuplicateBrep(); dup.TryGetDoorEntity().HBObject.Properties.Energy = dialog_rc; Rhino.RhinoDoc.ActiveDoc.Objects.Replace(ent.HostObjRef.ObjectId, dup); Rhino.RhinoDoc.ActiveDoc.EndUndoRecord(undo); } } }
public static HoneybeeSchema.Door ToLadybugTools(this IOpening opening, BuildingModel buildingModel, Space space) { if (opening == null || buildingModel == null) { return(null); } OpeningType openingType = opening.Type(); if (openingType == null) { return(null); } //Opaque Windows to be replaced by Doors if (opening is Window && buildingModel.GetMaterialType(openingType.PaneMaterialLayers) != MaterialType.Opaque) { return(null); } IHostPartition hostPartition = buildingModel.GetHostPartition(opening); int index = -1; int index_Adjacent = -1; List <Space> spaces = null; if (hostPartition != null) { spaces = buildingModel.GetSpaces(hostPartition); if (spaces != null && spaces.Count != 0) { index = spaces.FindIndex(x => x.Guid == space.Guid); index = buildingModel.UniqueIndex(spaces[index]); index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); } } HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = null; if (index == -1 || index_Adjacent == -1) { anyOf = new Outdoors(); } else { bool reversed = index_Adjacent < index; List <string> uniqueNames = new List <string>(); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(opening as SAMObject, index_Adjacent)); uniqueNames.Add(Query.UniqueName(hostPartition, index_Adjacent)); uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent])); anyOf = new Surface(uniqueNames); } Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(opening); DoorEnergyPropertiesAbridged doorEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(construction: Query.UniqueName(opening.Type(), !(index_Adjacent != -1 && index <= index_Adjacent))); return(new HoneybeeSchema.Door( identifier: Core.LadybugTools.Query.UniqueName(opening as SAMObject, index), geometry: face3D, boundaryCondition: anyOf, properties: new DoorPropertiesAbridged(doorEnergyPropertiesAbridged), displayName: opening.Name)); }