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)
An Idf 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
.
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.
An IdfObject object.
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.
if (FALSE) { # \dontrun{
model <- read_idf(system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr"))
# get an IdfObject using object ID
idf_object(model, 14)
# get an IdfObject using object name (case-insensitive)
idf_object(model, "zone one")
# `class` argument is useful when there are objects with same name in
# different class
idf_object(model, "zone one", "Zone")
# create a new zone
eplusr_option(validate_level = "draft")
zone <- idf_object(model, class = "Zone")
zone
eplusr_option(validate_level = "final")
zone$validate()
} # }