Run black on IOS-Python

This commit is contained in:
Dion Moult
2024-07-26 12:00:28 +10:00
parent d51fa2c5f7
commit a6286293d8
83 changed files with 603 additions and 637 deletions
+25 -15
View File
@@ -1,18 +1,28 @@
import time
import ifcopenshell
for i in range(3):
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}")
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
for j in range(i):
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.))),
)
])
f.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
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}")
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
for j in range(i):
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.write(f"{'fail' if i == 2 else 'pass'}-{i}-projects-ifc2x3.ifc")
+6 -5
View File
@@ -1,13 +1,14 @@
import ifcopenshell
for i, box_alignment in enumerate(['top-left', 'center', 'invalid', 'CENTER']):
for i, box_alignment in enumerate(["top-left", "center", "invalid", "CENTER"]):
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcTextLiteralWithExtent(
"My presentable text",
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))),
'RIGHT',
f.createIfcPlanarExtent(10., 10.),
box_alignment
f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))),
"RIGHT",
f.createIfcPlanarExtent(10.0, 10.0),
box_alignment,
)
f.write(f"{'pass' if i in (0,1) else 'fail'}-{i}-box-alignment-{box_alignment}-ifc2x3.ifc")
+15 -6
View File
@@ -28,11 +28,20 @@ for i, (is_valid, lat) in enumerate(latitudes):
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.))),
)
])
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])
f.write(f"{'pass' if is_valid else 'fail'}-site-latitude-{i}-ifc2x3.ifc")
+5 -10
View File
@@ -1,18 +1,13 @@
import ifcopenshell
for depth in (-1., 0., 1.):
for depth in (-1.0, 0.0, 1.0):
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcExtrudedAreaSolid(
f.createIfcRectangleProfileDef(
"AREA", None,
f.createIfcAxis2Placement2D(
f.createIfcCartesianPoint((0., 0.))
), 1., 1.
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
),
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.))
),
f.createIfcDirection((0., 0., 1.)),
depth
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
f.createIfcDirection((0.0, 0.0, 1.0)),
depth,
)
f.write(f"{'pass' if depth > 0. else 'fail'}-extrusion-depth-{depth}-ifc2x3.ifc")
+4 -2
View File
@@ -1,6 +1,8 @@
import ifcopenshell
for i, (r1, r2) in enumerate([("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]):
for i, (r1, r2) in enumerate(
[("SUPPLIER", None), ("SUPPLIER", "Valid"), ("USERDEFINED", "Valid"), ("USERDEFINED", None)]
):
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcActorRole(r1, r2)
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
f.write(f"{'fail' if i == 3 else 'pass'}-actor-role-{r1}-{r2}-ifc2x3.ifc")
+11 -7
View File
@@ -1,18 +1,22 @@
import ifcopenshell
options = {
'IfcPostalAddress': ({}, {'Country': 'The Netherlands'}, {'Country': 'The Netherlands', 'Town': 'Eindhoven'}),
'IfcTelecomAddress': ({}, {'TelephoneNumbers': ['040-12345678']}, {'TelephoneNumbers': ['040-12345678'], 'PagerNumber': '12345'})
"IfcPostalAddress": ({}, {"Country": "The Netherlands"}, {"Country": "The Netherlands", "Town": "Eindhoven"}),
"IfcTelecomAddress": (
{},
{"TelephoneNumbers": ["040-12345678"]},
{"TelephoneNumbers": ["040-12345678"], "PagerNumber": "12345"},
),
}
for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
for purpose in (None, 'USERDEFINED', 'HOME'):
for ud in (None, 'SomethingUserdefined'):
for ent in ("IfcPostalAddress", "IfcTelecomAddress"):
for purpose in (None, "USERDEFINED", "HOME"):
for ud in (None, "SomethingUserdefined"):
f = ifcopenshell.file(schema="IFC2X3")
f.create_entity(ent, purpose, None, ud, **options[ent][1])
valid = not (purpose == 'USERDEFINED' and ud is None)
valid = not (purpose == "USERDEFINED" and ud is None)
f.write(f"{'pass' if valid else 'fail'}-{ent}-{purpose}-{ud}-ifc2x3.ifc")
@@ -21,5 +25,5 @@ for ent in ('IfcPostalAddress', 'IfcTelecomAddress'):
f.create_entity(ent, **kwargs)
valid = len(kwargs) >= 1
if not valid:
kwargs = {'all-unset': 1}
kwargs = {"all-unset": 1}
f.write(f"{'pass' if valid else 'fail'}-{ent}-{'-'.join(kwargs.keys())}-ifc2x3.ifc")
+3 -3
View File
@@ -2,13 +2,13 @@ import itertools
import time
import ifcopenshell
for pty, ety in itertools.product(('GRILLE', 'USERDEFINED'), (None, 'Something')):
for pty, ety in itertools.product(("GRILLE", "USERDEFINED"), (None, "Something")):
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()))
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, 'My Type', ElementType=ety, PredefinedType=pty)
valid = pty != 'USERDEFINED' or ety is not None
f.createIfcAirTerminalType(ifcopenshell.guid.new(), ownerhist, "My Type", ElementType=ety, PredefinedType=pty)
valid = pty != "USERDEFINED" or ety is not None
f.write(f"{'pass' if valid else 'fail'}-air-terminal-type-{pty}-{ety}-ifc2x3.ifc")
+10 -4
View File
@@ -1,10 +1,16 @@
import ifcopenshell
create_none = lambda f: None
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
create_point = lambda f: f.createIfcCartesianPoint((0., 0.))
create_polyline = lambda f: f.createIfcPolyline(
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
)
create_point = lambda f: f.createIfcCartesianPoint((0.0, 0.0))
for i, make_item in enumerate((create_none, create_polyline, create_point)):
f = ifcopenshell.file(schema="IFC2X3")
inst = f.createIfcAnnotationCurveOccurrence(make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])])
f.write(f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc")
inst = f.createIfcAnnotationCurveOccurrence(
make_item(f), [f.createIfcPresentationStyleAssignment([f.createIfcCurveStyle()])]
)
f.write(
f"{'fail' if i == 2 else 'pass'}-annotation-curve-occurence-{'None' if inst.Item is None else inst.Item.is_a()}-ifc2x3.ifc"
)
+4 -2
View File
@@ -1,7 +1,9 @@
import ifcopenshell
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))
create_polyline = lambda f: f.createIfcPolyline((f.createIfcCartesianPoint((0., 0.)), f.createIfcCartesianPoint((1., 0.))))
create_plane = lambda f: f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))
create_polyline = lambda f: f.createIfcPolyline(
(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcCartesianPoint((1.0, 0.0)))
)
for i, make_item in enumerate((create_plane, create_polyline)):
f = ifcopenshell.file(schema="IFC2X3")
+8 -14
View File
@@ -1,22 +1,16 @@
import ifcopenshell
pts = [(0., 0.), (1., 0.), (1., 1.)]
dims = [
(2,3,3),
(3,3,2),
(2,2,2),
(3,3,3)
]
pts = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0)]
dims = [(2, 3, 3), (3, 3, 2), (2, 2, 2), (3, 3, 3)]
def make_point(xy, dim):
return f.createIfcCartesianPoint((xy + (0.,))[0:dim])
return f.createIfcCartesianPoint((xy + (0.0,))[0:dim])
for d in dims:
f = ifcopenshell.file(schema="IFC2X3")
inst = f.createIfcBSplineCurve(1,
list(map(lambda t: make_point(*t), zip(pts, d))),
"POLYLINE_FORM",
False,
False
inst = f.createIfcBSplineCurve(1, list(map(lambda t: make_point(*t), zip(pts, d))), "POLYLINE_FORM", False, False)
f.write(
f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc"
)
f.write(f"{'pass' if len(set(d)) == 1 else 'fail'}-bspline-curve-point-dimensions-{'-'.join(map(str, d))}-ifc2x3.ifc")
+4 -4
View File
@@ -1,8 +1,8 @@
import itertools
import ifcopenshell
defaults = {'Girth': 1., 'WallThickness': 0.11}
depths = [2., 3.]
defaults = {"Girth": 1.0, "WallThickness": 0.11}
depths = [2.0, 3.0]
widths = [0.2, 0.3]
for d, w in itertools.product(depths, widths):
@@ -12,9 +12,9 @@ for d, w in itertools.product(depths, widths):
f = ifcopenshell.file(schema="IFC2X3")
valid = (Girth < (Depth / 2.)) and ((WallThickness < Width/2.) and (WallThickness < Depth/2.))
valid = (Girth < (Depth / 2.0)) and ((WallThickness < Width / 2.0) and (WallThickness < Depth / 2.0))
inst = f.createIfcCShapeProfileDef(
'AREA', None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0., 0.))), **D
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), **D
)
f.write(f"{'pass' if valid else 'fail'}-cshape-profile-width-{w}-depth-{d}-ifc2x3.ifc")
+10 -15
View File
@@ -1,34 +1,29 @@
import ifcopenshell
depth = 1.0
for (dir_x, dir_z) in ((0., -1.), (0., 0.), (1., 0.), (1., 0.001), (0., 1.)):
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']
if (dir_x, dir_z) == (0., 0.):
schemas.append('IFC4')
schemas = ["IFC2X3"]
if (dir_x, dir_z) == (0.0, 0.0):
schemas.append("IFC4")
for schema in schemas:
f = ifcopenshell.file(schema=schema)
f.createIfcExtrudedAreaSolid(
f.createIfcRectangleProfileDef(
"AREA", None,
f.createIfcAxis2Placement2D(
f.createIfcCartesianPoint((0., 0.))
), 1., 1.
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
),
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.))
),
f.createIfcDirection((dir_x, 0., dir_z)),
depth
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
f.createIfcDirection((dir_x, 0.0, dir_z)),
depth,
)
# Due to the way IfcDotProduct and IfcNormalise interact, (0 0 0) actually
# results into indeterminate. But in IFC4 onwars there is a rule in IfcDirection
# for non-zero magnitude
valid = dir_z != 0.
if f.schema == 'IFC2X3' and (dir_x, dir_z) == (0., 0.):
valid = dir_z != 0.0
if f.schema == "IFC2X3" and (dir_x, dir_z) == (0.0, 0.0):
valid = True
f.write(f"{'pass' if valid else 'fail'}-extrusion-dir-{dir_x}-{dir_z}-{f.schema.lower()}.ifc")
+11 -19
View File
@@ -1,9 +1,9 @@
import ifcopenshell
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
make_3d = lambda cs: [c + (0.,) for c in cs]
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
make_3d = lambda cs: [c + (0.0,) for c in cs]
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
old_map = map
map = lambda fn, *args: list(old_map(fn, *args))
@@ -16,7 +16,7 @@ f.createIfcArbitraryProfileDefWithVoids(
[
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
]
],
)
f.write(f"pass-arbitrary-profile-with-voids-ifc2x3.ifc")
@@ -28,7 +28,7 @@ f.createIfcArbitraryProfileDefWithVoids(
[
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
]
],
)
f.write(f"fail-arbitrary-profile-with-voids-curve-ifc2x3.ifc")
@@ -40,7 +40,7 @@ f.createIfcArbitraryProfileDefWithVoids(
[
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_1)),
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
]
],
)
f.write(f"fail-arbitrary-profile-with-voids-3d-outer-ifc2x3.ifc")
@@ -52,7 +52,7 @@ f.createIfcArbitraryProfileDefWithVoids(
[
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
f.createIfcPolyline(map(f.createIfcCartesianPoint, inner_2)),
]
],
)
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-ifc2x3.ifc")
@@ -64,7 +64,7 @@ f.createIfcArbitraryProfileDefWithVoids(
[
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_1))),
f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(inner_2))),
]
],
)
f.write(f"fail-arbitrary-profile-with-voids-3d-inner-2-ifc2x3.ifc")
@@ -73,14 +73,6 @@ f.createIfcArbitraryProfileDefWithVoids(
"AREA",
None,
f.createIfcPolyline(map(f.createIfcCartesianPoint, coords)),
[
f.createIfcLine(
f.createIfcCartesianPoint((0., 0.)),
f.createIfcVector(
f.createIfcDirection((0., 0.)),
1.
)
)
]
[f.createIfcLine(f.createIfcCartesianPoint((0.0, 0.0)), f.createIfcVector(f.createIfcDirection((0.0, 0.0)), 1.0))],
)
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
f.write(f"fail-arbitrary-profile-with-voids-inner-line-ifc2x3.ifc")
+25 -27
View File
@@ -1,77 +1,75 @@
import ifcopenshell
coords = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
make_3d = lambda cs: [c + (0.,) for c in cs]
inner_1 = [(1., 1.), (2., 1.), (2., 2.), (1., 2.)]
inner_2 = [(3., 3.), (4., 3.), (4., 4.), (3., 4.)]
coords = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
make_3d = lambda cs: [c + (0.0,) for c in cs]
inner_1 = [(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)]
inner_2 = [(3.0, 3.0), (4.0, 3.0), (4.0, 4.0), (3.0, 4.0)]
old_map = map
map = lambda fn, *args: list(old_map(fn, *args))
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.))
)
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0)))
f.write(f"pass-axis2-3d-pos-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
f.createIfcDirection((0., 0., 1.)),
f.createIfcDirection((1., 0., 0.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
f.createIfcDirection((0.0, 0.0, 1.0)),
f.createIfcDirection((1.0, 0.0, 0.0)),
)
f.write(f"pass-axis2-two-directions-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
Axis=f.createIfcDirection((0., 0., 1.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
RefDirection=None,
)
f.write(f"fail-axis2-only-axis-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
Axis=None,
RefDirection=f.createIfcDirection((1., 0., 0.)),
RefDirection=f.createIfcDirection((1.0, 0.0, 0.0)),
)
f.write(f"fail-axis2-only-ref-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
f.createIfcDirection((1., 0.)),
f.createIfcDirection((0., 1., 0.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
f.createIfcDirection((1.0, 0.0)),
f.createIfcDirection((0.0, 1.0, 0.0)),
)
f.write(f"fail-axis2-2d-axis-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0.)),
f.createIfcCartesianPoint((0.0, 0.0)),
)
f.write(f"fail-axis2-2d-pos-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
f.createIfcDirection((0., 0., 1.)),
f.createIfcDirection((1., 0.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
f.createIfcDirection((0.0, 0.0, 1.0)),
f.createIfcDirection((1.0, 0.0)),
)
f.write(f"fail-axis2-2d-ref-ifc2x3.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
Axis=f.createIfcDirection((0., 0., 1.)),
RefDirection=f.createIfcDirection((0., 0., 1.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
RefDirection=f.createIfcDirection((0.0, 0.0, 1.0)),
)
f.write(f"fail-axis2-parallel-axes.ifc")
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.)),
Axis=f.createIfcDirection((0., 0., 1.)),
RefDirection=f.createIfcDirection((0., 0., -1.)),
f.createIfcCartesianPoint((0.0, 0.0, 0.0)),
Axis=f.createIfcDirection((0.0, 0.0, 1.0)),
RefDirection=f.createIfcDirection((0.0, 0.0, -1.0)),
)
f.write(f"fail-axis2-anti-parallel-axes.ifc")
+8 -15
View File
@@ -1,26 +1,19 @@
import ifcopenshell
dims = [
(1,0,0,0,0,0,0),
(1,1,0,0,0,0,0),
(0,1,0,0,0,0,0),
(-1,0,0,0,0,0,0),
(2,0,0,0,0,0,0),
(1, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 0),
(0, 1, 0, 0, 0, 0, 0),
(-1, 0, 0, 0, 0, 0, 0),
(2, 0, 0, 0, 0, 0, 0),
]
for i, d in enumerate(dims):
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcConversionBasedUnit(
f.createIfcDimensionalExponents(*d),
'LENGTHUNIT',
'beard-second',
f.createIfcMeasureWithUnit(
f.createIfcLengthMeasure(5.0),
f.createIfcSIUnit(
Prefix='NANO',
Name='METRE'
)
)
"LENGTHUNIT",
"beard-second",
f.createIfcMeasureWithUnit(f.createIfcLengthMeasure(5.0), f.createIfcSIUnit(Prefix="NANO", Name="METRE")),
)
f.write(f"{'pass' if i == 0 else 'fail'}-conv-unit-{i}-ifc2x3.ifc")
+59 -54
View File
@@ -1,72 +1,77 @@
import ifcopenshell
coords = [(0., 0.), (10., 0.)]
coords_2 = [(0., 0.), (10., 0.), (10., 10.), (0., 10.)]
make_3d = lambda cs: [c + (0.,) for c in cs]
make_nd = lambda d: lambda c: (c + (0.,)) if d == 3 else c
coords = [(0.0, 0.0), (10.0, 0.0)]
coords_2 = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]
make_3d = lambda cs: [c + (0.0,) for c in cs]
make_nd = lambda d: lambda c: (c + (0.0,)) if d == 3 else c
old_map = map
map = lambda fn, *args: list(old_map(fn, *args))
poly_2d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, coords))]
poly_3d = lambda f: [f.createIfcPolyline(map(f.createIfcCartesianPoint, make_3d(coords)))]
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0., 0., 0.))))]
fbsm = lambda f: [f.createIfcFaceBasedSurfaceModel(
FbsmFaces=[f.createIfcOpenShell(
CfsFaces=[f.createIfcFace(
Bounds=[f.createIfcFaceOuterBound(
Bound=f.createIfcPolyLoop(
Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2))
)
)]
)]
)]
)]
extrusion = lambda f: [f.createIfcExtrudedAreaSolid(
f.createIfcRectangleProfileDef(
"AREA", None,
f.createIfcAxis2Placement2D(
f.createIfcCartesianPoint((0., 0.))
), 1., 1.
),
f.createIfcAxis2Placement3D(
f.createIfcCartesianPoint((0., 0., 0.))
),
f.createIfcDirection((0., 0., 1.)),
1.
)]
bbox = lambda f: [f.createIfcBoundingBox(
f.createIfcCartesianPoint((0., 0., 0.)),
1., 1., 1.
)]
plane = lambda f: [f.createIfcPlane(f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))))]
fbsm = lambda f: [
f.createIfcFaceBasedSurfaceModel(
FbsmFaces=[
f.createIfcOpenShell(
CfsFaces=[
f.createIfcFace(
Bounds=[
f.createIfcFaceOuterBound(
Bound=f.createIfcPolyLoop(Polygon=map(f.createIfcCartesianPoint, make_3d(coords_2)))
)
]
)
]
)
]
)
]
extrusion = lambda f: [
f.createIfcExtrudedAreaSolid(
f.createIfcRectangleProfileDef(
"AREA", None, f.createIfcAxis2Placement2D(f.createIfcCartesianPoint((0.0, 0.0))), 1.0, 1.0
),
f.createIfcAxis2Placement3D(f.createIfcCartesianPoint((0.0, 0.0, 0.0))),
f.createIfcDirection((0.0, 0.0, 1.0)),
1.0,
)
]
bbox = lambda f: [f.createIfcBoundingBox(f.createIfcCartesianPoint((0.0, 0.0, 0.0)), 1.0, 1.0, 1.0)]
gcs = lambda fn: lambda f: [f.createIfcGeometricSet(fn(f))]
repeat = lambda n, fn: lambda f: fn(f) * n
options = [
(True, 2, 'Curve2D', '2d-polyline', poly_2d),
(False, 3, 'Curve2D', '3d-polyline', poly_3d),
(True, 2, 'GeometricCurveSet', 'with-curve', gcs(poly_2d)),
(False, 3, 'GeometricCurveSet', 'with-surface', gcs(plane)),
(False, 3, 'SurfaceModel', '3d-polyline', poly_3d),
(True, 3, 'SurfaceModel', 'surface-model', fbsm),
(False, 3, 'SweptSolid', '3d-polyline', poly_3d),
(True, 3, 'SweptSolid', 'extrusion', extrusion),
(True, 3, 'BoundingBox', 'single-bbox', bbox),
(False, 3, 'BoundingBox', 'multiple-bbox', repeat(2, bbox)),
(True, 2, "Curve2D", "2d-polyline", poly_2d),
(False, 3, "Curve2D", "3d-polyline", poly_3d),
(True, 2, "GeometricCurveSet", "with-curve", gcs(poly_2d)),
(False, 3, "GeometricCurveSet", "with-surface", gcs(plane)),
(False, 3, "SurfaceModel", "3d-polyline", poly_3d),
(True, 3, "SurfaceModel", "surface-model", fbsm),
(False, 3, "SweptSolid", "3d-polyline", poly_3d),
(True, 3, "SweptSolid", "extrusion", extrusion),
(True, 3, "BoundingBox", "single-bbox", bbox),
(False, 3, "BoundingBox", "multiple-bbox", repeat(2, bbox)),
]
for is_valid, dims, rep_type, name, fn in options:
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcProductDefinitionShape(Representations=[
f.createIfcShapeRepresentation(
f.createIfcGeometricRepresentationContext(
None, None, dims, None,
f.create_entity(f'IfcAxis2Placement{dims}D', f.createIfcCartesianPoint(make_nd(dims)((0., 0.)))),
),
'Body',
rep_type,
fn(f)
)
])
f.createIfcProductDefinitionShape(
Representations=[
f.createIfcShapeRepresentation(
f.createIfcGeometricRepresentationContext(
None,
None,
dims,
None,
f.create_entity(f"IfcAxis2Placement{dims}D", f.createIfcCartesianPoint(make_nd(dims)((0.0, 0.0)))),
),
"Body",
rep_type,
fn(f),
)
]
)
f.write(f"{'pass' if is_valid else 'fail'}-shaperep-{rep_type.lower()}-{name}-ifc2x3.ifc")
+3 -11
View File
@@ -1,10 +1,7 @@
import time
import ifcopenshell
names = [
("Same", "Same"),
("Different", "SomethingElse")
]
names = [("Same", "Same"), ("Different", "SomethingElse")]
make_prop = lambda f: lambda nm: f.createIfcPropertySingleValue(Name=nm)
@@ -19,11 +16,6 @@ for nms in names:
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
f.createIfcPropertySet(
ifcopenshell.guid.new(),
ownerhist,
"MyPset",
HasProperties=map(make_prop(f), nms)
)
f.createIfcPropertySet(ifcopenshell.guid.new(), ownerhist, "MyPset", HasProperties=map(make_prop(f), nms))
f.write(f"{'pass' if len(set(nms)) == len(nms) else 'fail'}-property-{'-'.join(map(str.lower, nms))}-ifc2x3.ifc")
15
15
+4 -10
View File
@@ -9,18 +9,12 @@ for i, nm in enumerate(("no-mls", "mls", "mlsu")):
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
wall = f.createIfcWallStandardCase(
ifcopenshell.guid.new(),
ownerhist
)
if i in (1,2):
wall = f.createIfcWallStandardCase(ifcopenshell.guid.new(), ownerhist)
if i in (1, 2):
mls = f.createIfcMaterialLayerSet([f.createIfcMaterialLayer(None, 0.1)])
if i == 2:
mls = f.createIfcMaterialLayerSetUsage(mls, 'AXIS2', 'POSITIVE', 0.)
mls = f.createIfcMaterialLayerSetUsage(mls, "AXIS2", "POSITIVE", 0.0)
f.createIfcRelAssociatesMaterial(
ifcopenshell.guid.new(),
ownerhist,
RelatedObjects=[wall],
RelatingMaterial=mls
ifcopenshell.guid.new(), ownerhist, RelatedObjects=[wall], RelatingMaterial=mls
)
f.write(f"{'pass' if i == 2 else 'fail'}-wall-{nm}-ifc2x3.ifc")
+5 -5
View File
@@ -1,12 +1,12 @@
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.createIfcRigidOperation(
SourceCRS=f.createIfcGeographicCRS('EPSG:4326'),
TargetCRS=f.createIfcGeographicCRS('EPSG:3857'),
SourceCRS=f.createIfcGeographicCRS("EPSG:4326"),
TargetCRS=f.createIfcGeographicCRS("EPSG:3857"),
FirstCoordinate=f.create_entity(type_decl, 0.0),
SecondCoordinate=f.create_entity('IfcPlaneAngleMeasure', 0.0),
Height=0.0
SecondCoordinate=f.create_entity("IfcPlaneAngleMeasure", 0.0),
Height=0.0,
)
f.write(f"{'pass' if i else 'fail'}-rigid-op-IfcPlaneAngleMeasure-{type_decl}-ifc4x3_add1.ifc")
+6 -8
View File
@@ -1,18 +1,16 @@
import ifcopenshell
make_nd = lambda d: lambda *c: (c + (0.,)) if d == 3 else c
make_nd = lambda d: lambda *c: (c + (0.0,)) if d == 3 else c
for d1, d2 in ((2,3), (3,3), (3,2)):
for d1, d2 in ((2, 3), (3, 3), (3, 2)):
f = ifcopenshell.file(schema="IFC2X3")
f.createIfcLocalPlacement(
PlacementRelTo=f.createIfcLocalPlacement(
PlacementRelTo=None,
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d1}D',
f.createIfcCartesianPoint(make_nd(d1)(0., 0.))
)
RelativePlacement=f.create_entity(
f"IfcAxis2Placement{d1}D", f.createIfcCartesianPoint(make_nd(d1)(0.0, 0.0))
),
),
RelativePlacement=f.create_entity(f'IfcAxis2Placement{d2}D',
f.createIfcCartesianPoint(make_nd(d2)(0., 0.))
)
RelativePlacement=f.create_entity(f"IfcAxis2Placement{d2}D", f.createIfcCartesianPoint(make_nd(d2)(0.0, 0.0))),
)
f.write(f"{'pass' if d1 >= d2 else 'fail'}-placement-{d1}d-{d2}d-ifc2x3.ifc")
+3 -3
View File
@@ -1,10 +1,10 @@
import ifcopenshell
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(),None,'sleep',IsMilestone=True)
task = lambda f: f.createIfcTask(ifcopenshell.guid.new(), None, "sleep", IsMilestone=True)
wall = lambda f: f.createIfcWall(ifcopenshell.guid.new())
for i,fn in enumerate((task, wall)):
for i, fn in enumerate((task, wall)):
f = ifcopenshell.file(schema="IFC4")
elem = fn(f)
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial('brick'))
f.createIfcRelAssociatesMaterial(ifcopenshell.guid.new(), None, None, None, [elem], f.createIfcMaterial("brick"))
f.write(f"{'pass' if i else 'fail'}-assoc-material-{elem.is_a()}-{f.schema}.ifc")
+20 -7
View File
@@ -1,13 +1,26 @@
import itertools
import ifcopenshell
def EXISTS(v): return v is not None
def NOT(v): return not v
for LiningDepth, LiningThickness in itertools.product((None, 1.), (None, 1.)):
def EXISTS(v):
return v is not None
def NOT(v):
return not v
for LiningDepth, LiningThickness in itertools.product((None, 1.0), (None, 1.0)):
f = ifcopenshell.file(schema="IFC4")
valid = NOT(EXISTS(LiningDepth) and NOT(EXISTS(LiningThickness)))
f.createIfcWindowType(ifcopenshell.guid.new(), None, 'WindowType', HasPropertySets=[
f.createIfcWindowLiningProperties(ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness)
])
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
f.createIfcWindowType(
ifcopenshell.guid.new(),
None,
"WindowType",
HasPropertySets=[
f.createIfcWindowLiningProperties(
ifcopenshell.guid.new(), LiningDepth=LiningDepth, LiningThickness=LiningThickness
)
],
)
f.write(f"{'pass' if valid else 'fail'}-lining-properties-{LiningDepth}-{LiningThickness}.ifc")
+41 -8
View File
@@ -1,21 +1,54 @@
import ifcopenshell
for cnt in range(0,3):
for cnt in range(0, 3):
f = ifcopenshell.file(schema="IFC4")
elem = f.createIfcWall(ifcopenshell.guid.new())
for i in range(cnt):
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
f.createIfcRelDefinesByProperties(
ifcopenshell.guid.new(),
None,
None,
None,
[elem],
f.createIfcPropertySet(
ifcopenshell.guid.new(),
None,
"Pset_WallCommon",
None,
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
),
)
f.write(f"{'pass' if cnt < 2 else 'fail'}-wall-{cnt}-same-psets.ifc")
f = ifcopenshell.file(schema="IFC4")
elem = f.createIfcWall(ifcopenshell.guid.new())
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Pset_WallCommon', None, [f.createIfcPropertySingleValue('LoadBearing', None, f.createIfcBoolean(True))])
f.createIfcRelDefinesByProperties(
ifcopenshell.guid.new(),
None,
None,
None,
[elem],
f.createIfcPropertySet(
ifcopenshell.guid.new(),
None,
"Pset_WallCommon",
None,
[f.createIfcPropertySingleValue("LoadBearing", None, f.createIfcBoolean(True))],
),
)
f.createIfcRelDefinesByProperties(ifcopenshell.guid.new(), None, None, None, [elem],
f.createIfcPropertySet(ifcopenshell.guid.new(), None, 'Custom', None, [f.createIfcPropertySingleValue('IsBeautiful', None, f.createIfcBoolean(True))])
f.createIfcRelDefinesByProperties(
ifcopenshell.guid.new(),
None,
None,
None,
[elem],
f.createIfcPropertySet(
ifcopenshell.guid.new(),
None,
"Custom",
None,
[f.createIfcPropertySingleValue("IsBeautiful", None, f.createIfcBoolean(True))],
),
)
f.write(f"pass-wall-different-psets.ifc")
f.write(f"pass-wall-different-psets.ifc")
+5 -5
View File
@@ -1,14 +1,14 @@
import ifcopenshell
fns = [
(False, lambda f: f.createIfcLengthMeasure(-1.)),
(True, lambda f: f.createIfcLengthMeasure(1.)),
(True, lambda f: f.createIfcPositiveLengthMeasure(1.)),
(False, lambda f: f.createIfcDescriptiveMeasure('large'))
(False, lambda f: f.createIfcLengthMeasure(-1.0)),
(True, lambda f: f.createIfcLengthMeasure(1.0)),
(True, lambda f: f.createIfcPositiveLengthMeasure(1.0)),
(False, lambda f: f.createIfcDescriptiveMeasure("large")),
]
for valid, fn in fns:
f = ifcopenshell.file(schema="IFC4")
fs = fn(f)
f.createIfcTextStyleFontModel('Comic Sans', ('Comic Sans',), FontSize=fs)
f.createIfcTextStyleFontModel("Comic Sans", ("Comic Sans",), FontSize=fs)
f.write(f"{'pass' if valid else 'fail'}-font-{fs.is_a()}-{fs[0]}.ifc")
+43 -18
View File
@@ -1,7 +1,18 @@
import time
import ifcopenshell
for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall', 'IfcSpace',)]:
for ents in [
("IfcWall",),
("IfcSpace",),
(
"IfcZone",
"IfcSpace",
),
(
"IfcWall",
"IfcSpace",
),
]:
f = ifcopenshell.file(schema="IFC2X3")
p = f.createIfcPerson(Id="tfk", GivenName="Thomas")
o = f.createIfcOrganization(Name="AECgeeks")
@@ -9,24 +20,38 @@ for ents in [('IfcWall',), ('IfcSpace',), ('IfcZone', 'IfcSpace',), ('IfcWall',
appl = f.createIfcApplication(o, ifcopenshell.version, "IfcOpenShell", f"IfcOpenShell {ifcopenshell.version}")
units = f.createIfcUnitAssignment(Units=[f.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE")])
ownerhist = f.createIfcOwnerHistory(pando, appl, ChangeAction="ADDED", CreationDate=int(time.time()))
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.))),
)
])
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))),
)
],
)
def elems():
for ent in ents:
el = f.create_entity(ent,
ifcopenshell.guid.new(),
ownerhist
)
if ent == 'IfcZone':
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(),
ownerhist)],RelatingGroup=el)
el = f.create_entity(ent, ifcopenshell.guid.new(), ownerhist)
if ent == "IfcZone":
f.createIfcRelAssignsToGroup(
ifcopenshell.guid.new(),
ownerhist,
RelatedObjects=[f.createIfcSpace(ifcopenshell.guid.new(), ownerhist)],
RelatingGroup=el,
)
yield el
zone = f.createIfcZone(ifcopenshell.guid.new(),ownerhist)
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(),ownerhist,RelatedObjects=list(elems()),RelatingGroup=zone)
f.createIfcRelAggregates(ifcopenshell.guid.new(),ownerhist,RelatingObject=proj,RelatedObjects=f.by_type('IfcSpace'))
valid = not (set(ents) - {'IfcZone', 'IfcSpace'})
zone = f.createIfcZone(ifcopenshell.guid.new(), ownerhist)
f.createIfcRelAssignsToGroup(ifcopenshell.guid.new(), ownerhist, RelatedObjects=list(elems()), RelatingGroup=zone)
f.createIfcRelAggregates(
ifcopenshell.guid.new(), ownerhist, RelatingObject=proj, RelatedObjects=f.by_type("IfcSpace")
)
valid = not (set(ents) - {"IfcZone", "IfcSpace"})
f.write(f"{'pass' if valid else 'fail'}-zone-with-{'-'.join(ents)}-{f.schema.lower()}.ifc")
+7 -5
View File
@@ -2,13 +2,15 @@ import ifcopenshell
segs = [
lambda _: None,
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((2,3))],
lambda f: [f.createIfcLineIndex((1,2)),f.createIfcLineIndex((1,2))]
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((2, 3))],
lambda f: [f.createIfcLineIndex((1, 2)), f.createIfcLineIndex((1, 2))],
]
for schema in ('ifc4', 'ifc4x3_add1'):
for schema in ("ifc4", "ifc4x3_add1"):
for i, seg in enumerate(segs):
f = ifcopenshell.file(schema=schema)
s = seg(f)
f.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0),(0.0, 1.0),(1.0, 1.0)]), s)
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.createIfcIndexedPolyCurve(f.createIfcCartesianPointList2D([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0)]), s)
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'
)