mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 06:02:45 +00:00
Allows key point referents to be nested to the parent alignment in the reusing horizontal scenario
This commit is contained in:
committed by
Dion Moult
parent
f65de78c46
commit
511584b36f
@@ -373,6 +373,41 @@ def test_start_station_composes_for_child_alignment():
|
||||
assert stations == pytest.approx([100.0, 600.0, 900.0])
|
||||
|
||||
|
||||
def test_rel_nests_from_ancestor_used_for_naming_and_nesting():
|
||||
"""A vertical layout living under a child alignment (once a second vertical layout is
|
||||
added, per CT 4.1.4.4.1.2) can still have its key-point referents named after and nested
|
||||
to an ancestor alignment's own rel_nests -- e.g. the same one already holding that
|
||||
ancestor's horizontal key points -- rather than the child's generic "Child of X" name."""
|
||||
file = _new_file()
|
||||
alignment = ifcopenshell.api.alignment.create(file, "A1", include_vertical=False, start_station=100.0)
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
horizontal_nest = ifcopenshell.api.alignment.update_key_point_referents(file, horizontal)
|
||||
horizontal_count = len(horizontal_nest.RelatedObjects)
|
||||
|
||||
ifcopenshell.api.alignment.add_vertical_layout(file, alignment)
|
||||
ifcopenshell.api.alignment.add_vertical_layout(file, alignment) # forces the child-alignment split
|
||||
child_alignment = alignment.IsDecomposedBy[0].RelatedObjects[-1]
|
||||
child_vertical = ifcopenshell.api.alignment.get_vertical_layout(child_alignment)
|
||||
|
||||
dp = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
HorizontalLength=500.0,
|
||||
StartHeight=10.0,
|
||||
StartGradient=0.01,
|
||||
EndGradient=0.01,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
ifcopenshell.api.alignment.create_layout_segment(file, child_vertical, dp)
|
||||
|
||||
result = ifcopenshell.api.alignment.update_key_point_referents(file, child_vertical, rel_nests=horizontal_nest)
|
||||
|
||||
assert result == horizontal_nest
|
||||
assert result.RelatingObject == alignment
|
||||
assert len(result.RelatedObjects) == horizontal_count + 2
|
||||
assert all(r.Name.startswith("A1 ") for r in result.RelatedObjects)
|
||||
assert not any("Child of" in r.Name for r in result.RelatedObjects)
|
||||
|
||||
|
||||
def test_returns_ifc_rel_nests():
|
||||
file = _new_file()
|
||||
alignment = _build_alignment(file)
|
||||
@@ -399,4 +434,5 @@ test_cant_layout_boundary_labels()
|
||||
test_no_real_segments_produces_no_referents()
|
||||
test_single_real_segment_produces_only_boundary_labels()
|
||||
test_start_station_composes_for_child_alignment()
|
||||
test_rel_nests_from_ancestor_used_for_naming_and_nesting()
|
||||
test_returns_ifc_rel_nests()
|
||||
|
||||
Reference in New Issue
Block a user