This commit is contained in:
Dion Moult
2026-07-26 18:03:09 +10:00
parent 7aa967b01a
commit 291d7d8441
72 changed files with 477 additions and 377 deletions
@@ -24,7 +24,6 @@ import ifcopenshell.api.context
import ifcopenshell.api.unit
from ifcopenshell.api.alignment._add_segment_to_layout import _add_segment_to_layout
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -24,7 +24,6 @@ import ifcopenshell.api.context
import ifcopenshell.api.unit
import ifcopenshell.util.element
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -25,7 +25,6 @@ import ifcopenshell.api.unit
import ifcopenshell.util
import ifcopenshell.util.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import pytest
import ifcopenshell.api.alignment
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -24,7 +24,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import pytest
import ifcopenshell.api.alignment
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -29,6 +29,7 @@ try:
except RuntimeError:
IFC4X3_AVAILABLE = False
def _BlossCurve_100_0_300_1000_1_Meter(file):
design_parameters = file.createIfcAlignmentCantSegment(
StartDistAlong=0.0,
@@ -33,6 +33,7 @@ try:
except RuntimeError:
IFC4X3_AVAILABLE = False
def _BlossCurve_100_0_300_1000_1_Meter(file):
design_parameters = file.createIfcAlignmentHorizontalSegment(
StartPoint=file.createIfcCartesianPoint((0.0, 0.0)),
@@ -32,6 +32,7 @@ try:
except RuntimeError:
IFC4X3_AVAILABLE = False
def _CircularArc_100_0_10_0_0_0_0_5_1_Meter(file):
design_parameters = file.createIfcAlignmentVerticalSegment(
StartDistAlong=0.0,
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -31,6 +31,7 @@ try:
except RuntimeError:
IFC4X3_AVAILABLE = False
def _test1():
file = ifcopenshell.file(schema="IFC4X3")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
@@ -22,7 +22,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -23,7 +23,6 @@ import ifcopenshell.api.alignment
import ifcopenshell.api.context
import ifcopenshell.api.unit
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.aggregate
import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.aggregate
import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -22,7 +22,6 @@ import ifcopenshell.api.aggregate
import ifcopenshell.api.cogo
import ifcopenshell.api.context
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True
@@ -20,6 +20,7 @@ import ifcopenshell
import pytest
import test.bootstrap
class TestGetInfo2(test.bootstrap.IFC4):
def test_instance_attribute(self):
brep = self.file.create_entity("IfcFacetedBrep")
@@ -65,25 +66,27 @@ class TestGetInfo2(test.bootstrap.IFC4):
"type": "IfcFacetedBrep",
}
def test_equality():
f = ifcopenshell.file()
g = ifcopenshell.file()
f.createIfcCartesianPoint((0., 0.))
g.createIfcCartesianPoint((0., 0.))
f.createIfcCartesianPoint((0.0, 0.0))
g.createIfcCartesianPoint((0.0, 0.0))
assert f[1] == g[1]
g[1].Coordinates = (1., 0.)
g[1].Coordinates = (1.0, 0.0)
assert f[1] != g[1]
def test_setting_logical():
f = ifcopenshell.file()
inst = f.createIfcPresentationLayerWithStyle(LayerOn="UNKNOWN")
assert inst.LayerOn == "UNKNOWN"
assert '.U.' in str(inst)
assert ".U." in str(inst)
with pytest.raises(Exception):
inst.LayerOn = "SOME_OTHER_STRING"
inst.LayerOn = False
assert inst.LayerOn is False
assert '.F.' in str(inst)
assert ".F." in str(inst)
inst.LayerOn = True
assert inst.LayerOn is True
assert '.T.' in str(inst)
assert ".T." in str(inst)
+6 -5
View File
@@ -21,13 +21,13 @@ import pytest
import ifcopenshell
import test.bootstrap
try:
ifcopenshell.file(schema="IFC4X3")
IFC4X3_AVAILABLE = True
except RuntimeError:
IFC4X3_AVAILABLE = False
class TestTransaction(test.bootstrap.IFC4):
def test_that_nothing_happens_without_a_transaction(self):
wall = self.file.createIfcWall()
@@ -296,9 +296,10 @@ class TestFile(test.bootstrap.IFC4):
g.assign_header_from(f)
assert g.header.file_name.name == "test"
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
def test_schema_identifier():
f = ifcopenshell.file(schema='IFC4X3')
assert f.schema_identifier == 'IFC4X3_ADD2'
assert f.schema == 'IFC4X3'
assert f.schema_version == (4,3,2,0)
f = ifcopenshell.file(schema="IFC4X3")
assert f.schema_identifier == "IFC4X3_ADD2"
assert f.schema == "IFC4X3"
assert f.schema_version == (4, 3, 2, 0)
@@ -1,5 +1,6 @@
import ifcopenshell
def test_skip_over_non_entity_instance():
data = """
ISO-10303-21;
+2 -1
View File
@@ -8,6 +8,7 @@ import tabulate
import ifcopenshell.express.rule_executor
import ifcopenshell.validate
@pytest.mark.parametrize(
"filename",
[
@@ -45,4 +46,4 @@ def test_file(filename):
if __name__ == "__main__":
pytest.main(["-sx", __file__, '--import-mode=importlib'])
pytest.main(["-sx", __file__, "--import-mode=importlib"])
@@ -9,19 +9,20 @@ import ifcopenshell.util.shape
from pathlib import Path
repo_root = Path(__file__).resolve().parent.parent.parent.parent
test_files = repo_root / 'test' / 'input' / 'tests'
test_files = repo_root / "test" / "input" / "tests"
settings = ifcopenshell.geom.settings()
testdata = list(csv.reader((test_files / 'data.csv').open(newline='')))[1:]
testdata = list(csv.reader((test_files / "data.csv").open(newline="")))[1:]
print(testdata)
@pytest.mark.parametrize("fn,area,volume", testdata)
def test_conversion(fn, area, volume):
f = ifcopenshell.open(test_files / fn)
elem = next(inst for inst in f.by_type('IfcElement') if not inst.is_a('IfcOpeningElement'))
for kernel in ('manifold', 'opencascade', 'cgal'):
elem = next(inst for inst in f.by_type("IfcElement") if not inst.is_a("IfcOpeningElement"))
for kernel in ("manifold", "opencascade", "cgal"):
shp = ifcopenshell.geom.create_shape(settings, elem, geometry_library=kernel)
if area:
assert pytest.approx(float(area), rel=0.05) == ifcopenshell.util.shape.get_area(shp.geometry)
@@ -22,7 +22,6 @@ import ifcopenshell
import ifcopenshell.api.unit
import ifcopenshell.util.alignment as sta
try:
ifcopenshell.file(schema="IFC4X3_ADD2")
IFC4X3_AVAILABLE = True