mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 10:59:17 +00:00
Add ifcquery CLI tool for IFC model interrogation (#7845)
ifcquery is a new command-line tool for querying and inspecting IFC models. All output is JSON.
Subcommands:
summary — schema version, entity counts, project metadata
tree — full spatial hierarchy (Project → Site → Building → Storeys → Spaces → Elements)
info <id> — deep inspection of any entity by step ID (attributes, psets, placement matrix, type, material)
select <query> — filter elements using ifcopenshell selector syntax
relations <id> — relationships for an element; --traverse up walks to IfcProject
clash <id> — geometric intersection and clearance detection
validate — schema/constraint validation; --rules adds EXPRESS checks
schedule — work schedules with nested task trees
cost — cost schedules with nested cost item trees
schema <class> — IFC class documentation from the model's schema version
plot — SVG plan drawing
render — 3D geometry rendering
contexts — geometric representation contexts
materials — material assignments
Usage:
python3 -m ifcquery <file.ifc> <subcommand> [args]
Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# This file was generated with the assistance of an AI coding tool.
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.project
|
||||
|
||||
from ifcquery.summary import summary
|
||||
|
||||
|
||||
class TestSummary:
|
||||
def test_schema(self, model):
|
||||
result = summary(model)
|
||||
assert result["schema"] == "IFC4"
|
||||
|
||||
def test_total_entities(self, model):
|
||||
result = summary(model)
|
||||
assert result["total_entities"] == len(list(model))
|
||||
assert result["total_entities"] > 0
|
||||
|
||||
def test_project_info(self, model):
|
||||
result = summary(model)
|
||||
assert result["project"]["name"] == "TestProject"
|
||||
|
||||
def test_type_counts(self, model):
|
||||
result = summary(model)
|
||||
types = result["types"]
|
||||
assert "IfcWall" in types
|
||||
assert types["IfcWall"] == 1
|
||||
assert "IfcSlab" in types
|
||||
assert types["IfcSlab"] == 1
|
||||
|
||||
def test_empty_model(self):
|
||||
f = ifcopenshell.api.project.create_file()
|
||||
result = summary(f)
|
||||
assert result["schema"] == "IFC4"
|
||||
assert "project" not in result
|
||||
Reference in New Issue
Block a user