idf_object() takes a parent Idf object, an object name or class name, and returns a corresponding IdfObject.

idf_object(parent, object = NULL, class = NULL)

Arguments

parent

An Idf object.

object

A valid object ID (an integer) or name (a string). If NULL and class is not NULL, an empty IdfObject is created with all fields fill with default values if possible. Default: NULL.

class

A valid class name (a string). If object is not NULL, class is used to further specify what class is the target object belongs to. If object is NULL, an empty IdfObject of class is created.

Value

An IdfObject object.

Details

If object is not given, an empty IdfObject of specified class is created, with all field values filled with defaults, if possible. Note that validation is performed when creating, which means that an error may occur if current validate level does not allow empty required fields.

The empty IdfObject is directly added into the parent Idf object. It is recommended to use $validate() method in IdfObject to see what kinds of further modifications are needed for those empty fields and use $set() method to set field values.

Examples

# \dontrun{ model <- read_idf(system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr")) # get an IdfObject using object ID idf_object(model, 14)
#> <IdfObject: 'Material'> [ID:14] `C5 - 4 IN HW CONCRETE` #> Class: <Material> #> ├─ 1*: "C5 - 4 IN HW CONCRETE", !- Name #> │─ 2*: "MediumRough", !- Roughness #> │─ 3*: 0.1014984, !- Thickness {m} #> │─ 4*: 1.729577, !- Conductivity {W/m-K} #> │─ 5*: 2242.585, !- Density {kg/m3} #> │─ 6*: 836.8, !- Specific Heat {J/kg-K} #> │─ 7 : 0.9, !- Thermal Absorptance #> │─ 8 : 0.65, !- Solar Absorptance #> └─ 9 : 0.65; !- Visible Absorptance
# get an IdfObject using object name (case-insensitive) idf_object(model, "zone one")
#> <IdfObject: 'Zone'> [ID:18] `ZONE ONE` #> Class: <Zone> #> ├─ 1*: "ZONE ONE", !- Name #> │─ 2 : 0, !- Direction of Relative North {deg} #> │─ 3 : 0, !- X Origin {m} #> │─ 4 : 0, !- Y Origin {m} #> │─ 5 : 0, !- Z Origin {m} #> │─ 6 : 1, !- Type #> │─ 7 : 1, !- Multiplier #> │─ 8 : autocalculate, !- Ceiling Height {m} #> └─ 9 : autocalculate; !- Volume {m3}
# `class` argument is useful when there are objects with same name in # different class idf_object(model, "zone one", "Zone")
#> <IdfObject: 'Zone'> [ID:18] `ZONE ONE` #> Class: <Zone> #> ├─ 1*: "ZONE ONE", !- Name #> │─ 2 : 0, !- Direction of Relative North {deg} #> │─ 3 : 0, !- X Origin {m} #> │─ 4 : 0, !- Y Origin {m} #> │─ 5 : 0, !- Z Origin {m} #> │─ 6 : 1, !- Type #> │─ 7 : 1, !- Multiplier #> │─ 8 : autocalculate, !- Ceiling Height {m} #> └─ 9 : autocalculate; !- Volume {m3}
# create a new zone eplusr_option(validate_level = "draft")
#> $validate_level #> [1] "draft" #>
zone <- idf_object(model, class = "Zone")
#> New empty object [ID:54] in class 'Zone' created.
zone
#> <IdfObject: 'Zone'> [ID:54] #> Class: <Zone> #> └─ 1*: <"Blank">; !- Name
eplusr_option(validate_level = "final")
#> $validate_level #> [1] "final" #>
zone$validate()
#> ✖ [1] Errors found during validation. #> ════════════════════════════════════════════════════════════════════════════════ #> #> ── [1] Missing Required Field ────────────────────────────────────────────────── #> Fields below are required but values are not given: #> #> Class: <Zone> #> └─ Object [ID:54] #> └─ 1: <"Blank">; !- Name #> #>
# }