Fix ifcopenshell.file calls in rules fixtures, use simpler schema postfix

This commit is contained in:
Andrej730
2026-08-03 15:16:27 +05:00
parent 6edea83137
commit 8f67b905eb
9 changed files with 11 additions and 10 deletions
@@ -5,8 +5,8 @@ FILE_NAME('','2023-01-11T09:47:45',(),(),'IfcOpenShell v0.7.0-8a108f37','IfcOpen
FILE_SCHEMA(('IFC4X3_ADD2')); FILE_SCHEMA(('IFC4X3_ADD2'));
ENDSEC; ENDSEC;
DATA; DATA;
#1=IFCGEOGRAPHICCRS('EPSG:4326',$,$,$,$); #1=IFCGEOGRAPHICCRS('EPSG:4326',$,$,$,$,$);
#2=IFCGEOGRAPHICCRS('EPSG:3857',$,$,$,$); #2=IFCGEOGRAPHICCRS('EPSG:3857',$,$,$,$,$);
#3=IFCRIGIDOPERATION(#1,#2,IFCLENGTHMEASURE(0.),IFCPLANEANGLEMEASURE(0.),0.); #3=IFCRIGIDOPERATION(#1,#2,IFCLENGTHMEASURE(0.),IFCPLANEANGLEMEASURE(0.),0.);
ENDSEC; ENDSEC;
END-ISO-10303-21; END-ISO-10303-21;
+2 -1
View File
@@ -1,9 +1,10 @@
import ifcopenshell import ifcopenshell
import ifcopenshell.util.schema
depth = 1.0 depth = 1.0
for dir_x, dir_z in ((0.0, -1.0), (0.0, 0.0), (1.0, 0.0), (1.0, 0.001), (0.0, 1.0)): for dir_x, dir_z in ((0.0, -1.0), (0.0, 0.0), (1.0, 0.0), (1.0, 0.001), (0.0, 1.0)):
schemas = ["IFC2X3"] schemas: list[ifcopenshell.util.schema.IFC_SCHEMA] = ["IFC2X3"]
if (dir_x, dir_z) == (0.0, 0.0): if (dir_x, dir_z) == (0.0, 0.0):
schemas.append("IFC4") schemas.append("IFC4")
+2 -2
View File
@@ -1,7 +1,7 @@
import ifcopenshell import ifcopenshell
for i, type_decl in enumerate(("IfcLengthMeasure", "IfcPlaneAngleMeasure")): for i, type_decl in enumerate(("IfcLengthMeasure", "IfcPlaneAngleMeasure")):
f = ifcopenshell.file(schema="IFC4X3_ADD1") f = ifcopenshell.file(schema="IFC4X3")
f.createIfcRigidOperation( f.createIfcRigidOperation(
SourceCRS=f.createIfcGeographicCRS("EPSG:4326"), SourceCRS=f.createIfcGeographicCRS("EPSG:4326"),
TargetCRS=f.createIfcGeographicCRS("EPSG:3857"), TargetCRS=f.createIfcGeographicCRS("EPSG:3857"),
@@ -9,4 +9,4 @@ for i, type_decl in enumerate(("IfcLengthMeasure", "IfcPlaneAngleMeasure")):
SecondCoordinate=f.create_entity("IfcPlaneAngleMeasure", 0.0), SecondCoordinate=f.create_entity("IfcPlaneAngleMeasure", 0.0),
Height=0.0, Height=0.0,
) )
f.write(f"{'pass' if i else 'fail'}-rigid-op-IfcPlaneAngleMeasure-{type_decl}-ifc4x3_add1.ifc") f.write(f"{'pass' if i else 'fail'}-rigid-op-IfcPlaneAngleMeasure-{type_decl}-ifc4x3.ifc")
+2 -2
View File
@@ -6,11 +6,11 @@ segs = [
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((1, 2))], lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((1, 2))],
] ]
for schema in ("ifc4", "ifc4x3_add1"): for schema in ("IFC4", "IFC4X3"):
for i, seg in enumerate(segs): for i, seg in enumerate(segs):
f = ifcopenshell.file(schema=schema) f = ifcopenshell.file(schema=schema)
s = seg(f) s = seg(f)
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]), s) f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]), s)
f.write( f.write(
f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema}.ifc' f'{"fail" if i == 2 else "pass"}-poly-curve-{"no-segments" if s is None else "-".join(["-".join(map(str, x[0])) for x in s])}-{schema.lower()}.ifc'
) )
@@ -7,12 +7,12 @@ import ifcopenshell.api.root
guid1 = "3pdqyORIn8KBHZAhhtJ72T" guid1 = "3pdqyORIn8KBHZAhhtJ72T"
guid2 = "1sEzC8v31DshmvW5t5P631" guid2 = "1sEzC8v31DshmvW5t5P631"
for schema in ("ifc2x3", "ifc4", "ifc4x3"): for schema in ("IFC2X3", "IFC4", "IFC4X3"):
for status in ("fail", "pass"): for status in ("fail", "pass"):
f = ifcopenshell.file(schema=schema) f = ifcopenshell.file(schema=schema)
# setup IfcOwnerHistory # setup IfcOwnerHistory
if schema == "ifc2x3": if schema == "IFC2X3":
ifcopenshell.api.owner.add_application(f) ifcopenshell.api.owner.add_application(f)
person = ifcopenshell.api.owner.add_person(f) person = ifcopenshell.api.owner.add_person(f)
organization = ifcopenshell.api.owner.add_organisation(f) organization = ifcopenshell.api.owner.add_organisation(f)
@@ -23,5 +23,5 @@ for schema in ("ifc2x3", "ifc4", "ifc4x3"):
wall1.GlobalId = guid1 wall1.GlobalId = guid1
wall2.GlobalId = guid1 if status == "fail" else guid2 wall2.GlobalId = guid1 if status == "fail" else guid2
filename = f"{status}-{'not-' if status == 'pass' else ''}duplicated-guids-{schema}.ifc" filename = f"{status}-{'not-' if status == 'pass' else ''}duplicated-guids-{schema.lower()}.ifc"
f.write(Path(__file__).parent / filename) f.write(Path(__file__).parent / filename)