Objects¶
IDFObject represents a single EnergyPlus object (e.g. a Zone or a
Material). Fields are accessed as snake_case Python attributes.
IDFCollection is a name-indexed container of objects that share the same
EnergyPlus type, providing O(1) lookup by name, iteration, and filtering.
Core object classes for IDF representation.
IDFObject: Thin wrapper around a dict with attribute access. IDFCollection: Indexed collection of IDFObjects with O(1) lookup.
IDFCollection
¶
Indexed collection of IDFObjects with O(1) lookup by name.
Provides list-like iteration and dict-like access by name.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Perimeter_ZN_1")
Zone('Perimeter_ZN_1')
>>> model.add("Zone", "Core_ZN")
Zone('Core_ZN')
>>> zones = model["Zone"]
>>> len(zones)
2
O(1) lookup by name:
Attributes:
| Name | Type | Description |
|---|---|---|
_type |
str
|
The object type this collection holds |
_by_name |
dict[str, IDFObject]
|
Dict mapping uppercase names to objects |
_items |
list[IDFObject]
|
Ordered list of objects |
Source code in src/idfkit/objects.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
by_name
property
¶
Dict mapping uppercase names to objects.
obj_type
property
¶
The object type this collection holds.
__getitem__(key)
¶
Get object by name or index.
Source code in src/idfkit/objects.py
add(obj)
¶
Add an object to the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
IDFObject
|
The IDFObject to add |
required |
Returns:
| Type | Description |
|---|---|
IDFObject
|
The added object |
Raises:
| Type | Description |
|---|---|
DuplicateObjectError
|
If an object with the same name exists |
Source code in src/idfkit/objects.py
filter(predicate)
¶
Filter objects by predicate function.
Examples:
Find zones on upper floors of a multi-story building:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Ground_Office", z_origin=0.0)
Zone('Ground_Office')
>>> model.add("Zone", "Floor2_Office", z_origin=3.5)
Zone('Floor2_Office')
>>> upper = model["Zone"].filter(lambda z: (z.z_origin or 0) > 0)
>>> [z.name for z in upper]
['Floor2_Office']
Source code in src/idfkit/objects.py
first()
¶
Get the first object or None.
Examples:
Quickly grab a singleton like Building or SimulationControl:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Core_ZN")
Zone('Core_ZN')
>>> model["Zone"].first().name
'Core_ZN'
>>> model["Material"].first() is None
True
Source code in src/idfkit/objects.py
get(name, default=None)
¶
Get object by name with default.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Perimeter_ZN_1")
Zone('Perimeter_ZN_1')
>>> model["Zone"].get("Perimeter_ZN_1").name
'Perimeter_ZN_1'
>>> model["Zone"].get("NonExistent") is None
True
Source code in src/idfkit/objects.py
remove(obj)
¶
Remove an object from the collection.
to_dict()
¶
Convert all objects to list of dicts (eppy compatibility).
Useful for feeding zone/material data into pandas or other analysis tools.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Perimeter_ZN_1", x_origin=0.0)
Zone('Perimeter_ZN_1')
>>> dicts = model["Zone"].to_dict()
>>> dicts[0]["name"]
'Perimeter_ZN_1'
Source code in src/idfkit/objects.py
to_list()
¶
Convert to list.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Perimeter_ZN_1")
Zone('Perimeter_ZN_1')
>>> model.add("Zone", "Core_ZN")
Zone('Core_ZN')
>>> [z.name for z in model["Zone"].to_list()]
['Perimeter_ZN_1', 'Core_ZN']
Source code in src/idfkit/objects.py
IDFObject
¶
Bases: EppyObjectMixin
Lightweight wrapper around a dict representing an EnergyPlus object.
Uses slots for memory efficiency - each object is ~200 bytes. Provides attribute access to fields via getattr/setattr.
Examples:
Create a rigid insulation material and access its properties:
>>> from idfkit import new_document
>>> model = new_document()
>>> insulation = model.add("Material", "XPS_50mm",
... roughness="Rough", thickness=0.05,
... conductivity=0.034, density=35.0, specific_heat=1400.0)
Read thermal properties as attributes:
Modify for parametric analysis (double the insulation):
Export to a dictionary for use with external tools:
Attributes:
| Name | Type | Description |
|---|---|---|
_type |
str
|
The IDF object type (e.g., "Zone", "Material") |
_name |
str
|
The object's name (first field) |
_data |
dict[str, Any]
|
Dict of field_name -> value |
_schema |
dict[str, Any] | None
|
Optional schema dict for validation |
_document |
IDFDocument | None
|
Reference to parent document (for reference resolution) |
_field_order |
list[str] | None
|
Ordered list of field names from schema |
Source code in src/idfkit/objects.py
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
data
property
¶
The field data dictionary.
field_order
property
¶
Ordered list of field names from schema.
mutation_version
property
¶
Monotonically increasing counter bumped on every field write.
Useful for caches that need to detect whether an object has been modified since a cached value was computed.
name
property
writable
¶
The object's name.
obj_type
property
¶
The IDF object type (e.g., 'Zone', 'Material').
schema_dict
property
¶
The schema dict for this object type.
__dir__()
¶
Return attributes for tab completion (includes schema field names).
Source code in src/idfkit/objects.py
__getattr__(key)
¶
Get field value by attribute name.
When the parent document has strict=True, accessing a field
name that is neither present in the data dict nor recognised by
the schema raises AttributeError instead of returning
None. This catches typos during migration.
Source code in src/idfkit/objects.py
__getitem__(key)
¶
Get field value by name or index.
Source code in src/idfkit/objects.py
__setattr__(key, value)
¶
Set field value by attribute name.
Source code in src/idfkit/objects.py
__setitem__(key, value)
¶
Set field value by name or index.
Source code in src/idfkit/objects.py
copy()
¶
Create a copy of this object.
Source code in src/idfkit/objects.py
get(key, default=None)
¶
Get field value with default.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> mat = model.add("Material", "Concrete_200mm",
... roughness="MediumRough", thickness=0.2,
... conductivity=1.4, density=2240.0, specific_heat=900.0)
>>> mat.get("conductivity")
1.4
>>> mat.get("thermal_absorptance", 0.9)
0.9
Source code in src/idfkit/objects.py
to_dict()
¶
Convert to dictionary representation.
Useful for serializing EnergyPlus objects to JSON, CSV, or DataFrames for post-processing.
Examples:
>>> from idfkit import new_document
>>> model = new_document()
>>> mat = model.add("Material", "Concrete_200mm",
... roughness="MediumRough", thickness=0.2,
... conductivity=1.4, density=2240.0, specific_heat=900.0)
>>> d = mat.to_dict()
>>> d["name"], d["thickness"], d["conductivity"]
('Concrete_200mm', 0.2, 1.4)
Source code in src/idfkit/objects.py
to_idf_name(python_name)
¶
Convert Python name back to IDF-style name.
'direction_of_relative_north' -> 'Direction of Relative North'
to_python_name(idf_name)
¶
Convert IDF field name to Python-friendly name.
'Direction of Relative North' -> 'direction_of_relative_north' 'X Origin' -> 'x_origin'