public static HoneybeeSchema.Aperture ToLadybugTools(this Aperture aperture, MaterialLibrary materialLibrary = null, int index = -1, int index_Adjacent = -1, string adjacentPanelUniqueName = null, string adjacentSpaceUniqueName = null) { if (aperture == null) { return(null); } if (aperture.ApertureType == ApertureType.Door) { return(null); } ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction == null) { return(null); } //Opaque Windows to be replaced by Doors if (apertureConstruction.PaneConstructionLayers.MaterialType(materialLibrary) == 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); } ApertureEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new ApertureEnergyPropertiesAbridged(Query.UniqueName(apertureConstruction, !(index_Adjacent != -1 && index <= index_Adjacent))); return(new HoneybeeSchema.Aperture( identifier: Core.LadybugTools.Query.UniqueName(aperture, index), geometry: face3D, boundaryCondition: anyOf, properties: new AperturePropertiesAbridged(apertureEnergyPropertiesAbridged), displayName: aperture.Name)); }
public void updateAperturePanel(ApertureEntity 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 = "Operable:" }); var operableCBox = new CheckBox(); operableCBox.CheckedBinding.Bind(apt, v => v.IsOperable); 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.ApertureEntity ent) { var energyProp = ent.HBObject.Properties.Energy ?? new ApertureEnergyPropertiesAbridged(); energyProp = ApertureEnergyPropertiesAbridged.FromJson(energyProp.ToJson()); var dialog = new UI.Dialog_ApertureEnergyProperty(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 aperture energy properties"); var dup = ent.HostObjRef.Brep().DuplicateBrep(); dup.TryGetApertureEntity().HBObject.Properties.Energy = dialog_rc; Rhino.RhinoDoc.ActiveDoc.Objects.Replace(ent.HostObjRef.ObjectId, dup); Rhino.RhinoDoc.ActiveDoc.EndUndoRecord(undo); } } }
public static HoneybeeSchema.Aperture ToLadybugTools(this Window window, BuildingModel buildingModel, Space space) { if (window == null || buildingModel == null) { return(null); } WindowType windowType = window.Type; if (windowType == null) { return(null); } //Opaque Windows to be replaced by Doors if (buildingModel.GetMaterialType(windowType.PaneMaterialLayers) == MaterialType.Opaque) { return(null); } IHostPartition hostPartition = buildingModel.GetHostPartition(window); 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(window, index_Adjacent)); uniqueNames.Add(Query.UniqueName(hostPartition, index_Adjacent)); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(spaces[index_Adjacent])); anyOf = new Surface(uniqueNames); } Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(window); ApertureEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new ApertureEnergyPropertiesAbridged(construction: Query.UniqueName(window.Type, !(index_Adjacent != -1 && index <= index_Adjacent))); return(new HoneybeeSchema.Aperture( identifier: Core.LadybugTools.Query.UniqueName(window, index), geometry: face3D, boundaryCondition: anyOf, properties: new AperturePropertiesAbridged(apertureEnergyPropertiesAbridged), displayName: window.Name)); }