Пример #1
0
        public void Test_SetProgramType()
        {
            var rhinoObj = InitRoomBox();
            var geo      = rhinoObj.Brep();

            var constructionset = EnergyLibrary.DefaultConstructionSets.First();
            var programtype     = EnergyLibrary.DefaultProgramTypes.First();
            var hvac            = EnergyLibrary.DefaultHVACs.First();

            var enertyProp = new HB.RoomEnergyPropertiesAbridged
                             (
                constructionSet: constructionset.Name,
                programType: programtype.Name,
                hvac: hvac.Name
                             );

            geo = HoneybeeRhino.SetRoomEnergyProperties(geo, enertyProp);

            var checkEnergyProp = geo.TryGetRoomEntity().GetEnergyProp();
            var constName       = checkEnergyProp.ConstructionSet;
            var typeName        = checkEnergyProp.ProgramType;
            var hvacName        = checkEnergyProp.Hvac;

            Assert.IsTrue(!string.IsNullOrEmpty(constName));
            Assert.IsTrue(!string.IsNullOrEmpty(typeName));
            Assert.IsTrue(!string.IsNullOrEmpty(hvacName));
        }
Пример #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
#if RELEASE
            Rhino.UI.Dialogs.ShowMessage("Good try, I have disabled this. This is only used for development!", "Honeybee");
            return(Result.Failure);
#endif


            var rc = Result.Cancel;
            RoomEnergyPropertiesAbridged roomEnergyProperties = new RoomEnergyPropertiesAbridged();

            if (mode == RunMode.Interactive)
            {
                var dialog = new UI.Dialog_RoomEnergyProperty(roomEnergyProperties);
                dialog.RestorePosition();
                var dialog_rc = dialog.ShowSemiModal(doc, RhinoEtoApp.MainWindow);
                dialog.SavePosition();
                if (dialog_rc != null)
                {
                    roomEnergyProperties = dialog_rc;
                    rc = Result.Success;
                }
            }
            else
            {
                var msg = string.Format($"Scriptable version of {EnglishName} command not implemented.");
                RhinoApp.WriteLine(msg);
            }

            if (roomEnergyProperties == null)
            {
                RhinoApp.WriteLine("No valid room energy property was set!");
                return(Result.Nothing);
            }

            //Get honeybee rooms
            using (var go = new GetObject())
            {
                go.SetCommandPrompt("Please select Honeybee Rooms to set its energy properties");

                go.GeometryFilter = ObjectType.Brep;
                go.GetMultiple(1, 0);
                if (go.CommandResult() != Result.Success)
                {
                    return(go.CommandResult());
                }

                if (go.ObjectCount == 0)
                {
                    return(Result.Nothing);
                }

                //get all Room Entities.
                var roomEnts = go.Objects().Select(_ => _.Geometry().TryGetRoomEntity()).Where(_ => _.IsValid);
                if (go.Objects().Length > roomEnts.Count())
                {
                    RhinoApp.WriteLine("Some selected geometries are not Honeybee room, please use MassToRoom to create rooms first!");
                    return(Result.Failure);
                }

                //Assign program types
                foreach (var item in go.Objects())
                {
                    var geo = item.Brep();
                    geo = HoneybeeRhino.SetRoomEnergyProperties(geo, roomEnergyProperties);
                    doc.Objects.Replace(item.ObjectId, geo);
                }

                doc.Views.Redraw();
                return(Result.Success);
            }
        }