Files
IfcOpenShell/src/ifcopenshell-python/test/fixtures/rules/generate_02.py
T
Andrej730 44ce7c7e8a rules fixture: nornallize headers
- to avoid some diffs on regeneration
- some fixtures had problems with the header, so `fail` for them wasn't
really testing the intended case, because small issues in the header
would make fixture fail regardless
2026-08-03 16:54:22 +05:00

51 lines
1.8 KiB
Python

import time
import ifcopenshell
from generate import normalize_header
latitudes = [
(False, (-361, 0, 0)),
(False, (-361, 0, 0, 0)),
(True, (-360, 0, 0, 0)),
(True, (0, 0, 0, 0)),
(True, (359, 0, 0, 0)),
(False, (360, 0, 0, 0)),
(True, (30, 30, 30)),
(False, (1000, 1000, 1000)),
(False, (0, 0, 1000)),
(False, (0, 0, 1000, 0)),
(True, (0, 0, 0, 100000)),
(True, (1, 1, 1, 1)),
(True, (-1, -1, -1, -1)),
(False, (-1, -1, 1, 1)),
(False, (1, -1, -1, -1)),
]
for i, (is_valid, lat) in enumerate(latitudes):
f = ifcopenshell.file(schema="IFC2X3")
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
o = f.createIfcOrganization(Name="AECgeeks")
pando = f.createIfcPersonAndOrganization(p, o)
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
site = f.createIfcSite(ifcopenshell.guid.new(), ownerhist, RefLatitude=lat)
proj = f.createIfcProject(
ifcopenshell.guid.new(),
ownerhist,
"My Project",
UnitsInContext=units,
RepresentationContexts=[
f.createIfcGeometricRepresentationContext(
None,
None,
3,
None,
f.create_entity(f"IfcAxis2Placement3D", f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
)
],
)
f.createIfcRelAggregates(ifcopenshell.guid.new(), ownerhist, None, None, proj, [site])
normalize_header(f)
f.write(f"{'pass' if is_valid else 'fail'}-site-latitude-{i}-ifc2x3.ifc")