-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayMaterialProperties.cs
86 lines (80 loc) · 3.42 KB
/
DisplayMaterialProperties.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Grasshopper.Kernel;
using Rhino.Geometry;
using System;
using System.Collections.Generic;
namespace WallSectionWidget
{
public class DisplayMaterialProperties : GH_Component
{
/// <summary>
/// Initializes a new instance of the DisplayMaterialProperties class.
/// </summary>
public DisplayMaterialProperties()
: base("DisplayMaterialProperties", "DMat",
"Display the material properties of a WSW Material definition",
"WallSectionWidget", "Visualisation")
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddScriptVariableParameter("WSWMaterial", "Mat", "WSW Material definition", GH_ParamAccess.item);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddTextParameter("Name", "N", "Name for this material", GH_ParamAccess.item);
pManager.AddNumberParameter("Conductivity", "C", "Thermal conductivity (W/mK)", GH_ParamAccess.item);
pManager.AddNumberParameter("Vapour resistance", "VR", "Water vapour diffusion resistance factor over ordinary air", GH_ParamAccess.item);
pManager.AddNumberParameter("Density", "D", "Density (kg/m3)", GH_ParamAccess.item);
pManager.AddNumberParameter("HeatCapacity", "HC", "Specific heat capacity (J/kgK)", GH_ParamAccess.item);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
GHIOParam<Material> MaterialGHIO = default;
if (!DA.GetData(0, ref MaterialGHIO))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Missing input: WSW Material definition");
return;
}
Material material;
if (!MaterialGHIO.GetContent(out material))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input error: WSWMaterial input is of wrong type");
return;
}
DA.SetData(0, material.Name);
DA.SetData(1, material.Conductivity);
DA.SetData(2, material.VapourResistivity);
DA.SetData(3, material.Density);
DA.SetData(4, material.HeatCapacity);
}
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon
{
get
{
//You can add image files to your project resources and access them like this:
// return Resources.IconForThisComponent;
return Properties.Resources.DisplayMaterial.ToBitmap();
}
}
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid
{
get { return new Guid("508b7a7d-5029-4cbc-8c7d-ec2dbbb261a3"); }
}
}
}