Class IdfReader
- Namespace
- EpNet
- Assembly
- EpNet.dll
Provides methods to manipulate an idf model by accessing to the different idf classes and their fields.
public class IdfReader : List<IdfObject>
- Inheritance
-
IdfReader
- Extension Methods
Examples
var Idf = new IdfReader();
foreach (var m in Idf["Material"].Where(m=>m["Name"].Contains("Insulation")))
m["Conductivity"].Number = 0.03;
Constructors
IdfReader()
Creates an IdfReader object loading in.idf and Energy+.idd from the standard DesignBuilder installation path.
public IdfReader()
IdfReader(string)
Creates an IdfReader object loading Energy+.idd from the standard DesignBuilder installation path.
public IdfReader(string idfFile)
Parameters
idfFile
stringPath to an idf file or a string with the contents of the file
IdfReader(string, Idd)
Creates an IdfReader object from an idf file path (or text content) and the Idd object from another IdfReader.
public IdfReader(string idfFile, Idd idd)
Parameters
idfFile
stringPath to an idf file or a string with the contents of the file
idd
IddReference to the Idd from another IdfReader
IdfReader(string, string)
Creates an IdfReader object from an idf file path (or text content) and the path to Energy+.idd file.
public IdfReader(string idfFile, string iddFilePath)
Parameters
idfFile
stringPath to an idf file or a string with the contents of the file
iddFilePath
stringPath to the Energy+.idd file corresponding to the E+ version of the idf file.
Properties
DsbFileName
Filename of the dsb file from which the idf has been generated.
public string DsbFileName { get; }
Property Value
- string
dsb filename
DsbFolder
Folder where the original dsb file is located.
public string DsbFolder { get; }
Property Value
- string
dsb file folder
DsbPath
Full path of the dsb file from which the idf has been generated.
public string DsbPath { get; }
Property Value
- string
Path of the dsb file.
EnergyPlusPath
public string EnergyPlusPath { get; set; }
Property Value
Idd
Reference to the Idd object that holds the variable names from the Energy+.idd
public Idd Idd { get; set; }
Property Value
- Idd
Idd object
Idf
Provides a single Idf instance to be shared between scripts.
public static IdfReader Idf { get; }
Property Value
IdfEncoding
public Encoding IdfEncoding { get; set; }
Property Value
IdfPath
Path to the idf file
public string IdfPath { get; set; }
Property Value
- string
Path to the loaded idf file
this[string]
List of all the idf objects from the specified idf class.
public List<IdfObject> this[string idfClass] { get; }
Parameters
idfClass
stringidf class to use as a filter
Property Value
Examples
var allZones = Idf["Zone"];
this[string[]]
List of all the idf objects from the specified idf classes.
public List<IdfObject> this[params string[] idfClasses] { get; }
Parameters
idfClasses
string[]idf classes to use as a filter
Property Value
Examples
var zoneEquipment = Idf["ZoneHVAC:FourPipeFanCoil","ZoneHVAC:PackagedTerminalAirConditioner","ZoneHVAC:PackagedTerminalHeatPump"];
Methods
Add(IdfObject)
public void Add(IdfObject value)
Parameters
value
IdfObject
AddDesignVariable(string, string, int, string)
Adds a design variable for parametric/optimisation. Use in BeforeEnergySimulation hook.
public void AddDesignVariable(string idfClass, string name, int field, string variableKey)
Parameters
idfClass
stringThe idf class for the object to modify. e.g. "Material"
name
stringName of the object to modify. e.g. Insulation (searches for a name starting by that)
field
intNumber of the field to change. e.g. 2
variableKey
stringName of the variable key given in DesignBuilder as Custom IDF. e.g. "insulationthickness"
Examples
Test different thickness values for a insulation material: AddDesignVariable("Material","Variable Insulation", 2, "insulationthickness"); Idf.Save();
AddDesignVariable(string, string, int, string, Func<double, double>)
Adds a design variable for parametric/optimisation. Use in BeforeEnergySimulation hook.
public void AddDesignVariable(string idfClass, string name, int field, string variableKey, Func<double, double> variableKeyFunction)
Parameters
idfClass
stringThe idf class for the object to modify. e.g. "Material"
name
stringName of the object to modify. e.g. Insulation (searches for a name starting by that)
field
intNumber of the field to change. e.g. 2
variableKey
stringName of the variable key given in DesignBuilder as Custom IDF e.g. "insulationthickness"
variableKeyFunction
Func<double, double>Function to apply to the variableKey
Examples
Test different thickness values for a insulation material: AddDesignVariable("Material","Variable Insulation", 2, "insulationthickness", x=>x/100); Idf.Save();
AddKpi(Environment, string, double)
Adds a Kpi result for parametric/optimisatin. Use in AfterEnergySimulation hook. Also as an extension method for DB.Api.Environment ApiEnvironment)
public void AddKpi(Environment ApiEnvironment, string kpiName, double kpiValue)
Parameters
Clone()
Returns a new cloned instance of the IdfReader
public IdfReader Clone()
Returns
- IdfReader
Cloned IdfReader instance
Clone(IdfObject)
Makes a copy of a specified idf object and add it to the idf model.
public void Clone(IdfObject idfObject)
Parameters
idfObject
IdfObjectidf object to clone.
GetByIdfClasses(IEnumerable<string>)
List of all the idf objects from the specified idf classes.
public List<IdfObject> GetByIdfClasses(IEnumerable<string> idfClasses)
Parameters
idfClasses
IEnumerable<string>idf classes to use as a filter
Returns
GetDataFromEso(string)
Retrieves a value from the eso file saved with the SaveDataInEso method.
public double? GetDataFromEso(string key)
Parameters
key
stringName of the key or variable to retrieve.
Returns
GetVariable(string)
Gets the value of the parametric variable defined in DesignBuilder optimization module as a Custom Idf variable.
public string GetVariable(string name)
Parameters
name
stringVariable key used in DesignBuilder
Returns
- string
String holding the value of the variable.
Load(string)
Loads a portion of idf to an existing idf model. Do not include comments.
public void Load(string idf)
Parameters
idf
stringText containing the idf to load.
Load(string[])
Loads a single IdfObject its sequence of elements
public void Load(string[] fields)
Parameters
fields
string[]idfclass, field1, field2 ...
ReadData(string)
Reads data from the precomments of the file
public string ReadData(string key)
Parameters
key
string
Returns
RemoveData(string)
Removes data from the precomments of the file
public void RemoveData(string key)
Parameters
key
string
Save(bool)
Saves the idf file overwriting the original.
public void Save(bool comments = true)
Parameters
comments
boolInclude idf comments in the file.
Save(string, bool, bool)
Saves the idf file.
public void Save(string idfFilePath, bool comments = true, bool ordered = false)
Parameters
idfFilePath
stringPath for the idf file. Use filename only to save in original idf folder.
comments
boolInclude idf comments in the file.
ordered
boolOrder idf clases by name.
SaveASCII(bool)
Saves the idf file overwriting the original.
public void SaveASCII(bool comments = true)
Parameters
comments
boolInclude idf comments in the file.
SaveASCII(string, bool, bool)
Saves the idf file removing diacritics (á,é,ü...) and Spanish ñ
public void SaveASCII(string idfFilePath, bool comments = true, bool ordered = false)
Parameters
idfFilePath
stringPath for the idf file. Use filename only to save in original idf folder.
comments
boolInclude idf comments in the file.
ordered
boolOrder idf clases by name.
SaveDataInEso(string, double)
Creates a numeric value than can be retrieved after simulation from the Eso results file.
public void SaveDataInEso(string key, double value)
Parameters
key
stringName of the key or variable to be used later for retrieval.
value
doubleValue of the variable
ToString()
Whole idf content as a text string.
public override string ToString()
Returns
- string
idf content.
WriteData(string, string)
Writes data to the precomments of the file
public void WriteData(string key, string value)