IfcQuery¶
IfcQuery is a CLI tool for querying and inspecting IFC building models. It provides read-only subcommands for common inspection tasks, all outputting JSON so results can be piped into other tools.
Subcommands:
summary — schema version, entity counts, project metadata
tree — full spatial hierarchy (IfcProject → Site → Building → Storeys → Spaces → Elements)
info — deep inspection of any entity by step ID (attributes, property sets, placement matrix, type, material)
select — filter elements by IFC class using the IfcOpenShell selector syntax
relations — relationships for an element; use
--traverse upto walk the hierarchy to IfcProjectclash — geometric intersection and clearance checks; requires the IfcOpenShell C++ geometry bindings
validate — schema and constraint validation; add
--rulesfor a full EXPRESS checkschedule — work schedules with nested task trees
cost — cost schedules with nested cost item trees
schema — IFC class documentation using the loaded model’s schema version
contexts — geometric representation contexts
materials — material definitions (IfcMaterial, layer sets, constituent sets, profile sets)
plot — generate a drawing (SVG or PNG) using
ifcopenshell.draw; PNG output requirescairosvgrender — off-screen 3D render to a PNG image; requires
pyvistaand the IfcOpenShell C++ geometry bindings
All subcommands accept --format json|text|ids to control output (default: json):
json— structured JSON, suitable for piping tojqorifcedit foreachtext— indented human-readable outputids— comma-separated step IDs extracted from list results, suitable for piping directly intoifcedit runparameters
Installation¶
pip install ifcquery
For PNG output from plot, also install cairosvg:
pip install cairosvg
For 3D rendering with render, also install pyvista:
pip install pyvista
Or install from source:
cd /path/to/IfcOpenShell/src/ifcquerypip install .
Usage¶
$ ifcquery model.ifc summary
$ ifcquery model.ifc tree
$ ifcquery model.ifc info 42
$ ifcquery model.ifc select 'IfcWall'
$ ifcquery model.ifc relations 42
$ ifcquery model.ifc relations 42 --traverse up
$ ifcquery model.ifc validate
$ ifcquery model.ifc validate --rules
$ ifcquery model.ifc schedule
$ ifcquery model.ifc cost
$ ifcquery model.ifc schema IfcWall
$ ifcquery model.ifc materials
$ ifcquery model.ifc plot -o floorplan.svg --out-format svg --view floorplan
$ ifcquery model.ifc plot -o floorplan.png --view floorplan
$ ifcquery model.ifc render -o model.png
$ ifcquery model.ifc --format ids select 'IfcWall'
Scripting with ifcedit¶
ifcquery and ifcedit are designed to compose. Use --format ids to
pass query results directly into ifcedit run parameters, or pipe JSON into
ifcedit foreach to apply an operation to every matching element:
# Aggregate — pass all IDs as a list parameter
$ ifcedit run model.ifc spatial.unassign_container \
--products "$(ifcquery model.ifc --format ids select 'IfcWall')"
# Fan-out — one operation per element, model opened and saved once
$ ifcquery model.ifc select 'IfcWindow' | ifcedit foreach model.ifc root.remove_product --product {id}
# Render an element highlighted against everything related to it
$ ifcquery model.ifc render -o relations.png \
--element "$(ifcquery model.ifc --format ids relations 42)"
# Render a clash — subject and clashing elements highlighted together
$ ifcquery model.ifc render -o clash.png \
--element "$(ifcquery model.ifc --format ids clash 42)"