Skip to content

Use yaml for easy geometry declaration#117

Merged
alexandrecuer merged 7 commits into
mainfrom
geometry_from_yaml
Jun 5, 2026
Merged

Use yaml for easy geometry declaration#117
alexandrecuer merged 7 commits into
mainfrom
geometry_from_yaml

Conversation

@alexandrecuer

Copy link
Copy Markdown
Contributor

implements

  • reusable blocks
  • yaml anchor use and string formulas
  • constructions, walls and floors
  • apertures and doors
  • single elements for specific aperture declaration

implements
- reusable blocks
- yaml anchor use and string formulas
- constructions, walls and floors
- apertures and doors
- single elements for specific aperture declaration
@obm-claude-bot

Copy link
Copy Markdown
Collaborator

In a Nutshell

This PR introduces YAML-based geometry declaration for the ladybug_codes project, replacing hardcoded Python geometry definitions. It implements reusable blocks, YAML anchors, string formula evaluation, and a new generate_geometry_from_yaml.py script that parses YAML configurations to build 3D buildings with walls, floors, apertures, and doors.

What Changed

New Files:

  • conf_geometry/agence.yml (118 additions): YAML configuration defining a building ("Agence_ACF") with multiple levels (basement, ground floor, meeting room, first floor), using YAML anchors (&rdc_alt, etc.) for coordinate reuse and declaring walls, apertures, and doors
  • generate_geometry_from_yaml.py (224 additions): Main script that parses the YAML geometry configuration and generates Honeybee Room objects with constructions and apertures
  • src/idfhub/helpers/matlib.py (15 additions): Construction material library mapping (wall_osb, wall_parpaing, floor_internal, window_pvc, simple_glass_wall)

Modified Files:

  • generate_geometry.py: Changed aperture type parameters from Door class reference to string "door" (4 lines)
  • src/idfhub/common.py (45 additions, 1 deletion): Added expression evaluation engine using AST (eval_expr function) to support string formulas in YAML, and new command-line argument --geoconf for specifying geometry config file
  • src/idfhub/helpers/geometry.py (27 additions, 24 deletions): Refactored add_aperture() to accept string aperture types instead of class types, improved logging (switched to %s formatting), extracted set_u_v_bounds() as separate method, updated type hints

Key Features

YAML Configuration Format - Declarative building geometry with readable structure
YAML Anchors & References - Reuse altitude and coordinate blocks
String Formulas - Evaluate expressions like "altitude+2" in coordinates
Construction Library - Centralized construction definitions
Flexible Apertures - Support arrays of aperture properties or defaults per wall
Type Safety - Type hints throughout, string-based aperture types for consistency

Code Quality Notes

Positive:

  • Separates declarative config from imperative code
  • Safe expression evaluator (AST-based, not eval())
  • Logging improvements (parameterized formatting)

Considerations:

  • No error handling shown for invalid YAML or missing construction keys
  • generate_geometry_from_yaml.py is long (~224 lines) with nested loops; could benefit from further modularization
  • No tests visible in the PR
  • Expression evaluator supports only basic arithmetic; complex formulas will fail silently

@alexandrecuer alexandrecuer added this to the version 0.0.1 milestone Jun 5, 2026
@alexandrecuer alexandrecuer merged commit 5f3643e into main Jun 5, 2026
@alexandrecuer alexandrecuer deleted the geometry_from_yaml branch June 5, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants