Show interactive 3D building geometry from the loaded model.
Renders detailed building surfaces, fenestration, and shading geometry in a
Three.js viewport with orbit controls, placed where EnergyPlus simulates
them (zone origins, zone rotations and the building north axis applied).
Click surfaces to inspect properties; toggle visibility by surface type or
zone. Surfaces that cannot be placed and simplified geometry types (for
example Wall:Exterior or Window) are not drawn; they are listed in the
payload and in the text summary.
Source code in src/idfkit_mcp/tools/geometry.py
| @tool(
annotations=_READ_ONLY,
meta={
"ui": app_config_to_meta_dict(
AppConfig(
resourceUri="ui://idfkit/geometry-viewer.html",
prefersBorder=False,
)
)
},
)
def view_geometry(
color_by: Annotated[
Literal["type", "zone"],
Field(description="Color surfaces by type (wall/floor/roof/window) or zone."),
] = "type",
) -> ToolResult:
"""Show interactive 3D building geometry from the loaded model.
Renders detailed building surfaces, fenestration, and shading geometry in a
Three.js viewport with orbit controls, placed where EnergyPlus simulates
them (zone origins, zone rotations and the building north axis applied).
Click surfaces to inspect properties; toggle visibility by surface type or
zone. Surfaces that cannot be placed and simplified geometry types (for
example Wall:Exterior or Window) are not drawn; they are listed in the
payload and in the text summary.
"""
scene = get_scene(get_state().require_model())
data = _extract_geometry(scene, color_by)
count = len(scene.surfaces)
zone_count = len(_zone_names(scene))
logger.info("Extracted %d surfaces across %d zones for geometry viewer", count, zone_count)
# Build a text summary for clients that don't support MCP Apps.
type_counts = Counter(_surface_type(s) for s in scene.surfaces)
breakdown = ", ".join(f"{c} {t}" for t, c in sorted(type_counts.items()))
summary = f"Model geometry: {count} surfaces across {zone_count} zones ({breakdown})."
skipped = _skipped_summary(scene)
if skipped:
summary = f"{summary} {skipped}"
# The content array is delivered to the viewer via ontoolresult.
# Non-Apps hosts display the text content to the LLM as a fallback.
return ToolResult(
content=[
TextContent(type="text", text=json.dumps(data)),
TextContent(type="text", text=summary),
]
)
|