コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Model" /> class.
        /// </summary>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="rooms">A list of Rooms in the model..</param>
        /// <param name="orphanedFaces">A list of Faces in the model that lack a parent Room. Note that orphaned Faces are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="orphanedShades">A list of Shades in the model that lack a parent..</param>
        /// <param name="orphanedApertures">A list of Apertures in the model that lack a parent Face. Note that orphaned Apertures are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="orphanedDoors">A list of Doors in the model that lack a parent Face. Note that orphaned Doors are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="units">Text indicating the units in which the model geometry exists. This is used to scale the geometry to the correct units for simulation engines like EnergyPlus, which requires all geometry be in meters..</param>
        /// <param name="tolerance">The maximum difference between x, y, and z values at which vertices are considered equivalent. This value should be in the Model units and it is used in a variety of checks, including checks for whether Room faces form a closed volume and subsequently correcting all face normals point outward from the Room. A value of 0 will result in bypassing all checks so it is recommended that this always be a positive number when such checks have not already been performed on a Model. The default of 0.01 is suitable for models in meters. (default to 0.01D).</param>
        /// <param name="angleTolerance">The max angle difference in degrees that vertices are allowed to differ from one another in order to consider them colinear. This value is used in a variety of checks, including checks for whether Room faces form a closed volume and subsequently correcting all face normals point outward from the Room. A value of 0 will result in bypassing all checks so it is recommended that this always be a positive number when such checks have not already been performed on a given Model. (default to 1.0D).</param>
        /// <param name="identifier">Text string for a unique object ID. This identifier remains constant as the object is mutated, copied, and serialized to different formats (eg. dict, idf, rad). This identifier is also used to reference the object across a Model. It must be &lt; 100 characters and not contain any spaces or special characters. (required).</param>
        /// <param name="displayName">Display name of the object with no character restrictions..</param>
        /// <param name="userData">Optional dictionary of user data associated with the object.All keys and values of this dictionary should be of a standard data type to ensure correct serialization of the object (eg. str, float, int, list)..</param>
        public Model
        (
            string identifier, ModelProperties properties,                                                                                                                                                                                                                                                                                         // Required parameters
            string displayName = default, Object userData = default, List <Room> rooms = default, List <Face> orphanedFaces = default, List <Shade> orphanedShades = default, List <Aperture> orphanedApertures = default, List <Door> orphanedDoors = default, Units units = Units.Meters, double tolerance = 0.01D, double angleTolerance = 1.0D // Optional parameters
        ) : base(identifier: identifier, displayName: displayName, userData: userData)                                                                                                                                                                                                                                                             // BaseClass
        {
            // to ensure "properties" is required (not null)
            this.Properties        = properties ?? throw new ArgumentNullException("properties is a required property for Model and cannot be null");
            this.Rooms             = rooms;
            this.OrphanedFaces     = orphanedFaces;
            this.OrphanedShades    = orphanedShades;
            this.OrphanedApertures = orphanedApertures;
            this.OrphanedDoors     = orphanedDoors;
            this.Units             = units;
            this.Tolerance         = tolerance;
            this.AngleTolerance    = angleTolerance;

            // Set non-required readonly properties with defaultValue
            this.Type    = "Model";
            this.Version = "1.49.0";

            // check if object is valid, only check for inherited class
            if (this.GetType() == typeof(Model))
            {
                this.IsValid(throwException: true);
            }
        }
コード例 #2
0
        public ProgramTypeManagerViewModel(HB.ModelProperties libSource, Control control = default) : base(control)
        {
            _modelProperties = libSource;

            this._userData   = libSource.Energy.ProgramTypeList.OfType <ProgramTypeAbridged>().Select(_ => new ProgramTypeViewData(_)).ToList();
            this._systemData = SystemEnergyLib.ProgramTypeList.OfType <ProgramTypeAbridged>().Select(_ => new ProgramTypeViewData(_)).ToList();
            this._allData    = _userData.Concat(_systemData).Distinct(_viewDataComparer).ToList();

            ResetDataCollection();
        }
コード例 #3
0
        public Dialog_ShadeProperty(HB.ModelProperties libSource, List <HB.Shade> faces)
        {
            try
            {
                libSource.FillNulls();

                Title       = $"Shade Properties - {DialogHelper.PluginName}";
                WindowStyle = WindowStyle.Default;
                this.Icon   = DialogHelper.HoneybeeIcon;

                var p = new DynamicLayout();
                p.DefaultSpacing = new Size(4, 4);
                p.DefaultPadding = new Padding(4);


                var panel = ShadeProperty.Instance;
                p.AddRow(panel);
                panel.UpdatePanel(libSource, faces);

                var OKButton = new Button()
                {
                    Text = "OK"
                };
                OKButton.Click += (s, e) =>
                {
                    try
                    {
                        this.Close(panel.GetShades());
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message);
                        //throw;
                    }
                };

                AbortButton = new Button {
                    Text = "Cancel"
                };
                AbortButton.Click += (sender, e) => Close();

                p.AddSeparateRow(null, null, OKButton, this.AbortButton, null, panel.SchemaDataBtn);
                p.Add(null);
                this.Content = p;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                //throw;
            }
        }
コード例 #4
0
 public void UpdatePanel(HB.ModelProperties libSource, List <HB.Shade> objs)
 {
     this._vm.Update(libSource, objs);
 }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Model" /> class.
        /// </summary>
        /// <param name="name">Name of the object used in all simulation engines. Must not contain spaces and use only letters, digits and underscores/dashes. It cannot be longer than 100 characters. (required).</param>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="displayName">Display name of the object with no restrictions..</param>
        /// <param name="type">type (default to &quot;Model&quot;).</param>
        /// <param name="rooms">A list of Rooms in the model..</param>
        /// <param name="orphanedFaces">A list of Faces in the model that lack a parent Room. Note that orphaned Faces are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="orphanedShades">A list of Shades in the model that lack a parent..</param>
        /// <param name="orphanedApertures">A list of Apertures in the model that lack a parent Face. Note that orphaned Apertures are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="orphanedDoors">A list of Doors in the model that lack a parent Face. Note that orphaned Doors are not acceptable for Models that are to be exported for energy simulation..</param>
        /// <param name="northAngle">The clockwise north direction in degrees. (default to 0).</param>
        /// <param name="units">Text indicating the units in which the model geometry exists. This is used to scale the geometry to the correct units for simulation engines like EnergyPlus, which requires all geometry be in meters. (default to UnitsEnum.Meters).</param>
        /// <param name="tolerance">The maximum difference between x, y, and z values at which vertices are considered equivalent. This value should be in the Model units and it is used in a variety of checks, including checks for whether Room faces form a closed volume and subsequently correcting all face normals point outward from the Room. A value of 0 will result in no attempt to evaluate whether Room volumes are closed or check face direction. So it is recommended that this always be a positive number when such checks have not been performed on a Model. Typical tolerances for builing geometry range from 0.1 to 0.0001 depending on the units of the geometry. (default to 0).</param>
        /// <param name="angleTolerance">The max angle difference in degrees that vertices are allowed to differ from one another in order to consider them colinear. This value is used in a variety of checks, including checks for whether Room faces form a closed volume and subsequently correcting all face normals point outward from the Room. A value of 0 will result in no attempt to evaluate whether the Room volumes is closed or check face direction. So it is recommended that this always be a positive number when such checks have not been performed on a given Model. Typical tolerances for builing geometry are often around 1 degree. (default to 0).</param>
        public Model(string name, ModelProperties properties, string displayName = default, string type = "Model", List <Room> rooms = default, List <Face> orphanedFaces = default, List <Shade> orphanedShades = default, List <Aperture> orphanedApertures = default, List <Door> orphanedDoors = default, double northAngle = 0, UnitsEnum?units = UnitsEnum.Meters, double tolerance = 0, double angleTolerance = 0)
        {
            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new InvalidDataException("name is a required property for Model and cannot be null");
            }
            else
            {
                this.Name = name;
            }

            // to ensure "properties" is required (not null)
            if (properties == null)
            {
                throw new InvalidDataException("properties is a required property for Model and cannot be null");
            }
            else
            {
                this.Properties = properties;
            }

            this.DisplayName = displayName;
            // use default value if no "type" provided
            if (type == null)
            {
                this.Type = "Model";
            }
            else
            {
                this.Type = type;
            }
            this.Rooms             = rooms;
            this.OrphanedFaces     = orphanedFaces;
            this.OrphanedShades    = orphanedShades;
            this.OrphanedApertures = orphanedApertures;
            this.OrphanedDoors     = orphanedDoors;
            // use default value if no "northAngle" provided
            if (northAngle == null)
            {
                this.NorthAngle = 0;
            }
            else
            {
                this.NorthAngle = northAngle;
            }
            // use default value if no "units" provided
            if (units == null)
            {
                this.Units = UnitsEnum.Meters;
            }
            else
            {
                this.Units = units;
            }
            // use default value if no "tolerance" provided
            if (tolerance == null)
            {
                this.Tolerance = 0;
            }
            else
            {
                this.Tolerance = tolerance;
            }
            // use default value if no "angleTolerance" provided
            if (angleTolerance == null)
            {
                this.AngleTolerance = 0;
            }
            else
            {
                this.AngleTolerance = angleTolerance;
            }
        }
コード例 #6
0
        public Dialog_ProgramType(ref HB.ModelProperties libSource, HB.ProgramTypeAbridged programType, bool lockedMode = false)
        {
            try
            {
                libSource.FillNulls();

                _vm = new ProgramTypeViewModel(this, ref libSource, programType);

                Title       = $"Program Type - {DialogHelper.PluginName}";
                WindowStyle = WindowStyle.Default;
                Width       = 450;
                this.Icon   = DialogHelper.HoneybeeIcon;


                //Generate ProgramType Panel

                var nameTbx = new TextBox();
                nameTbx.TextBinding.Bind(_vm, c => c.Name);

                var loadGroup = GenLoadsPanel(lockedMode);


                var locked = new CheckBox()
                {
                    Text = "Locked", Enabled = false
                };
                locked.Checked = lockedMode;

                var OkButton = new Button {
                    Text = "OK", Enabled = !lockedMode
                };
                OkButton.Click += (sender, e) => {
                    try
                    {
                        OkCommand.Execute(_vm.GetHBObject());
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message);
                        //throw;
                    }
                };

                AbortButton = new Button {
                    Text = "Cancel"
                };
                AbortButton.Click += (sender, e) => Close();

                // Json Data
                var hbData = new Button {
                    Text = "Schema Data"
                };
                hbData.Command = _vm.HBDataBtnClick;

                //Create layout
                var layout = new DynamicLayout()
                {
                    DefaultPadding = new Padding(5), DefaultSpacing = new Size(5, 5)
                };
                layout.BeginScrollable(BorderType.None);

                layout.AddRow("Name");
                layout.AddRow(nameTbx);
                layout.AddRow(loadGroup);
                layout.AddRow(null);
                layout.EndScrollable();
                layout.AddSeparateRow(locked, null, OkButton, AbortButton, null, hbData);
                layout.Add(null);
                //Create layout
                Content = layout;
            }
            catch (Exception e)
            {
                //throw e;
                Dialog_Message.Show(e.ToString());
            }
        }