mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
7cd40bf8cb
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.
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
# This file was generated with the assistance of an AI coding tool.
|
|
import ifcopenshell
|
|
import ifcopenshell.api.aggregate
|
|
import ifcopenshell.api.owner.settings
|
|
import ifcopenshell.api.project
|
|
import ifcopenshell.api.root
|
|
import ifcopenshell.api.spatial
|
|
import ifcopenshell.api.unit
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def model():
|
|
"""Create an IFC4 model with a spatial hierarchy and a wall."""
|
|
f = ifcopenshell.api.project.create_file()
|
|
ifcopenshell.api.owner.settings.get_user = lambda ifc: (ifc.by_type("IfcPersonAndOrganization") or [None])[0]
|
|
ifcopenshell.api.owner.settings.get_application = lambda ifc: (ifc.by_type("IfcApplication") or [None])[0]
|
|
|
|
project = ifcopenshell.api.root.create_entity(f, ifc_class="IfcProject", name="TestProject")
|
|
ifcopenshell.api.unit.assign_unit(f)
|
|
|
|
site = ifcopenshell.api.root.create_entity(f, ifc_class="IfcSite", name="TestSite")
|
|
building = ifcopenshell.api.root.create_entity(f, ifc_class="IfcBuilding", name="TestBuilding")
|
|
storey = ifcopenshell.api.root.create_entity(f, ifc_class="IfcBuildingStorey", name="Ground Floor")
|
|
|
|
ifcopenshell.api.aggregate.assign_object(f, products=[site], relating_object=project)
|
|
ifcopenshell.api.aggregate.assign_object(f, products=[building], relating_object=site)
|
|
ifcopenshell.api.aggregate.assign_object(f, products=[storey], relating_object=building)
|
|
|
|
wall = ifcopenshell.api.root.create_entity(f, ifc_class="IfcWall", name="Wall001")
|
|
ifcopenshell.api.spatial.assign_container(f, products=[wall], relating_structure=storey)
|
|
|
|
slab = ifcopenshell.api.root.create_entity(f, ifc_class="IfcSlab", name="Slab001")
|
|
ifcopenshell.api.spatial.assign_container(f, products=[slab], relating_structure=storey)
|
|
|
|
return f
|