geom.stats module for preemptive scanning through file

This commit is contained in:
Thomas Krijnen
2025-10-25 13:58:32 +02:00
parent ea9e0c9ab4
commit 5910b39766
2 changed files with 268 additions and 0 deletions
@@ -0,0 +1,26 @@
import os
import ifcopenshell
from ifcopenshell.geom.stats import StatsCollector
import pytest
@pytest.mark.parametrize(
"file",
[os.path.join(os.path.dirname(__file__), "../../../../test/input/Allplan 2017 Test Bauteil-Oberflächen.ifc")],
)
def test_stats(file):
collector = StatsCollector.fromFilePath(file)
while not collector.finalized:
collector.process()
collector.print()
prio = {
"IfcWall": 2,
"IfcBuildingElement": 1,
"IfcBuildingElementProxy": -1,
}
ents = [a.name() for a in collector.includeElementTypesBasedOnBudget(prio, 1)]
assert ents == ["IfcWall"] or ents == ["IfcWallStandardCase"]
ents = [a.name() for a in collector.includeElementTypesBasedOnBudget(prio, 100)]
assert "IfcBuildingElementProxy" in ents
ents = [a.name() for a in collector.includeElementTypesBasedOnBudget(prio, 50)]
assert "IfcBuildingElementProxy" not in ents