This commit is contained in:
Andrej730
2025-07-09 13:47:32 +05:00
parent 40f92d15c3
commit 5a4ad69bf7
30 changed files with 362 additions and 301 deletions
@@ -24,9 +24,9 @@ import ifcopenshell.api.context
def test_create_alignment():
file = ifcopenshell.file(schema="IFC4X3_ADD2")
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file,units=[length])
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
ifcopenshell.api.unit.assign_unit(file, units=[length])
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
file,
@@ -36,34 +36,36 @@ def test_create_alignment():
parent=geometric_representation_context,
)
include_vertical = [False,True,True]
include_vertical = [False, True, True]
include_cant = [False, False, True]
expected_curve_type = ["IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"]
expected_curve_type = ["IfcCompositeCurve", "IfcGradientCurve", "IfcSegmentedReferenceCurve"]
for i in range(0,3) :
ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i])
for i in range(0, 3):
ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i])
assert ali != None
# verify the geometric representation was created
curve = ifcopenshell.api.alignment.get_curve(ali)
assert(curve.is_a() == expected_curve_type[i])
assert curve.is_a() == expected_curve_type[i]
assert len(curve.Segments) == 1
horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali)
vert = ifcopenshell.api.alignment.get_vertical_layout(ali)
cant = ifcopenshell.api.alignment.get_cant_layout(ali)
assert horiz != None
if include_vertical[i]:
assert vert != None
if include_cant[i]:
assert cant != None
# verify each layout has a zero length segment (which also tests if the geometry curve has a zero length segment)
alignments = [horiz,vert,cant]
alignments = [horiz, vert, cant]
for a in alignments:
if a != None:
segments = ifcopenshell.api.alignment.get_layout_segments(a)
assert len(segments) == 1
assert ifcopenshell.api.alignment.has_zero_length_segment(a) # there is a check in this function for the geometry curve
assert ifcopenshell.api.alignment.has_zero_length_segment(
a
) # there is a check in this function for the geometry curve