mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
alignment: rename get_referent_nest to get_stationing_nest
This commit is contained in:
@@ -79,7 +79,7 @@ from .get_layout_curve import get_layout_curve
|
||||
from .get_layout_segments import get_layout_segments
|
||||
from .get_mapped_segments import get_mapped_segments
|
||||
from .get_parent_alignment import get_parent_alignment
|
||||
from .get_referent_nest import get_referent_nest
|
||||
from .get_stationing_nest import get_stationing_nest
|
||||
from .get_vertical_layout import get_vertical_layout
|
||||
from .has_zero_length_segment import has_zero_length_segment
|
||||
from .layout_horizontal_alignment_by_pi_method import (
|
||||
@@ -124,7 +124,7 @@ __all__ = [
|
||||
"get_layout_curve",
|
||||
"get_layout_segments",
|
||||
"get_parent_alignment",
|
||||
"get_referent_nest",
|
||||
"get_stationing_nest",
|
||||
"get_vertical_layout",
|
||||
"has_zero_length_segment",
|
||||
"layout_horizontal_alignment_by_pi_method",
|
||||
|
||||
@@ -114,7 +114,7 @@ def add_stationing_referent(
|
||||
pset_stationing = ifcopenshell.api.pset.add_pset(file, product=referent, name="Pset_Stationing")
|
||||
ifcopenshell.api.pset.edit_pset(file, pset=pset_stationing, properties=properties)
|
||||
|
||||
nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
if nest is None:
|
||||
nest = file.createIfcRelNests(
|
||||
GlobalId=ifcopenshell.guid.new(), RelatingObject=alignment, RelatedObjects=(referent,)
|
||||
|
||||
@@ -64,22 +64,22 @@ def create_representation(
|
||||
|
||||
# if the alignment is created without geometry it's stationing referent isn't related to the alignment geometry.
|
||||
# the stationing referent needs to be updated to have an IfcLinearPlacement that references the basis curve geometry
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
if (
|
||||
referent_nest
|
||||
and 0 < len(referent_nest.RelatedObjects)
|
||||
and referent_nest.RelatedObjects[0].ObjectPlacement
|
||||
and not referent_nest.RelatedObjects[0].ObjectPlacement.is_a("IfcLinearPlacement")
|
||||
stationing_nest
|
||||
and 0 < len(stationing_nest.RelatedObjects)
|
||||
and stationing_nest.RelatedObjects[0].ObjectPlacement
|
||||
and not stationing_nest.RelatedObjects[0].ObjectPlacement.is_a("IfcLinearPlacement")
|
||||
):
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
|
||||
if referent_nest.RelatedObjects[0].ObjectPlacement:
|
||||
if referent_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.Location:
|
||||
file.remove(referent_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.Location)
|
||||
if referent_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.RefDirection:
|
||||
file.remove(referent_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.RefDirection)
|
||||
file.remove(referent_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement)
|
||||
file.remove(referent_nest.RelatedObjects[0].ObjectPlacement)
|
||||
if stationing_nest.RelatedObjects[0].ObjectPlacement:
|
||||
if stationing_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.Location:
|
||||
file.remove(stationing_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.Location)
|
||||
if stationing_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.RefDirection:
|
||||
file.remove(stationing_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement.RefDirection)
|
||||
file.remove(stationing_nest.RelatedObjects[0].ObjectPlacement.RelativePlacement)
|
||||
file.remove(stationing_nest.RelatedObjects[0].ObjectPlacement)
|
||||
|
||||
lp = file.createIfcLinearPlacement(
|
||||
RelativePlacement=file.createIfcAxis2PlacementLinear(
|
||||
@@ -93,4 +93,4 @@ def create_representation(
|
||||
)
|
||||
)
|
||||
update_fallback_position(file, lp)
|
||||
referent_nest.RelatedObjects[0].ObjectPlacement = lp
|
||||
stationing_nest.RelatedObjects[0].ObjectPlacement = lp
|
||||
|
||||
@@ -67,8 +67,8 @@ def distance_along_from_station(file: ifcopenshell.file, alignment: entity_insta
|
||||
print(dist_along) # 100.00
|
||||
"""
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
if referent_nest is None:
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
if stationing_nest is None:
|
||||
start_station = ifcopenshell.api.alignment.get_alignment_start_station(file, alignment)
|
||||
return station - start_station
|
||||
|
||||
@@ -77,7 +77,7 @@ def distance_along_from_station(file: ifcopenshell.file, alignment: entity_insta
|
||||
_distance_along_of_referent(referent),
|
||||
ifcopenshell.util.element.get_pset(referent, name="Pset_Stationing", prop="Station"),
|
||||
)
|
||||
for referent in referent_nest.RelatedObjects
|
||||
for referent in stationing_nest.RelatedObjects
|
||||
]
|
||||
stations.sort(key=lambda entry: entry[0])
|
||||
|
||||
|
||||
+9
-3
@@ -20,12 +20,18 @@ import ifcopenshell
|
||||
from ifcopenshell import entity_instance
|
||||
|
||||
|
||||
def get_referent_nest(file: ifcopenshell.file, alignment: entity_instance) -> entity_instance:
|
||||
def get_stationing_nest(file: ifcopenshell.file, alignment: entity_instance) -> entity_instance:
|
||||
"""
|
||||
Searches for the IfcRelNest that contains IfcReferent.
|
||||
Searches for the IfcRelNests that defines the alignment's stationing scheme.
|
||||
|
||||
The returned nest is nested to the IfcAlignment and its RelatedObjects contains only the
|
||||
IfcReferent(s) (PredefinedType="STATION") that establish the alignment's starting station and
|
||||
any station equations along it, as created by add_stationing_referent. It does not contain any
|
||||
other kind of referent (e.g. key-point referents from update_key_point_referents live in their
|
||||
own, separate IfcRelNests).
|
||||
|
||||
:param file:
|
||||
:param alignment: The IfcAlignment which hosts IfcReferent
|
||||
:param alignment: The IfcAlignment which hosts the stationing IfcReferent(s)
|
||||
:return: Returns the IfcRelNests or None
|
||||
"""
|
||||
if not alignment.is_a("IfcAlignment"):
|
||||
@@ -39,9 +39,9 @@ def test_add_segment_to_layout():
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "")
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert (
|
||||
len(referent_nest.RelatedObjects) == 1
|
||||
len(stationing_nest.RelatedObjects) == 1
|
||||
) # the alignment creates the stationing nest and it has one referent to defined the stationing for the alignment
|
||||
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
@@ -75,8 +75,8 @@ def test_add_segment_to_layout():
|
||||
assert len(horizontal_alignment.IsNestedBy) == 1
|
||||
segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(horizontal_alignment)
|
||||
assert len(segment_nest.RelatedObjects) == 2
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
assert len(referent_nest.RelatedObjects) == 1 # test this a second time to make sure that it is still true
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert len(stationing_nest.RelatedObjects) == 1 # test this a second time to make sure that it is still true
|
||||
|
||||
|
||||
test_add_segment_to_layout()
|
||||
|
||||
@@ -39,8 +39,8 @@ def test_add_stationing_to_alignment():
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", start_station=2000.0)
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
referent = referent_nest.RelatedObjects[0]
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
referent = stationing_nest.RelatedObjects[0]
|
||||
|
||||
assert referent.PredefinedType == "STATION"
|
||||
assert referent.Name == "2+000.000"
|
||||
@@ -54,10 +54,10 @@ def test_add_stationing_to_alignment():
|
||||
file, "4+000.000", alignment, distance_along=1000.0, station=4000.0, incoming_station=3000.0
|
||||
)
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
assert len(referent_nest.RelatedObjects) == 2
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert len(stationing_nest.RelatedObjects) == 2
|
||||
|
||||
assert second_referent == referent_nest.RelatedObjects[1]
|
||||
assert second_referent == stationing_nest.RelatedObjects[1]
|
||||
|
||||
assert second_referent.PredefinedType == "STATION"
|
||||
assert second_referent.Name == "4+000.000"
|
||||
|
||||
@@ -36,11 +36,11 @@ def test_add_vertical_alignment():
|
||||
layout_nest = ifcopenshell.api.alignment.get_alignment_layout_nest(alignment)
|
||||
assert len(layout_nest.RelatedObjects) == 1
|
||||
assert layout_nest.RelatedObjects[0].is_a("IfcAlignmentHorizontal")
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert (
|
||||
len(referent_nest.RelatedObjects) == 1
|
||||
len(stationing_nest.RelatedObjects) == 1
|
||||
) # the alignment creates the stationing nest and it has one referent to defined the stationing for the alignment
|
||||
assert referent_nest.RelatedObjects[0].is_a("IfcReferent")
|
||||
assert stationing_nest.RelatedObjects[0].is_a("IfcReferent")
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
@@ -51,8 +51,8 @@ def test_create_by_pi_method():
|
||||
layout_nest = ifcopenshell.api.alignment.get_alignment_layout_nest(alignment)
|
||||
assert len(layout_nest.RelatedObjects) == 2
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
assert len(referent_nest.RelatedObjects) == 1
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert len(stationing_nest.RelatedObjects) == 1
|
||||
|
||||
horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
horizontal_segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(horizontal_layout)
|
||||
|
||||
@@ -46,9 +46,9 @@ def test_horizontal_layout_by_pi_method():
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 2
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
layout_nest = ifcopenshell.api.alignment.get_alignment_layout_nest(alignment)
|
||||
assert referent_nest.RelatedObjects[0].is_a("IfcReferent")
|
||||
assert stationing_nest.RelatedObjects[0].is_a("IfcReferent")
|
||||
assert layout_nest.RelatedObjects[0].is_a("IfcAlignmentHorizontal")
|
||||
segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(layout_nest.RelatedObjects[0])
|
||||
assert len(segment_nest.RelatedObjects) == 3 # segments in horizontal layout
|
||||
|
||||
@@ -64,8 +64,8 @@ def test_vertical_layout_by_pi_method():
|
||||
layout_nest = ifcopenshell.api.alignment.get_alignment_layout_nest(alignment)
|
||||
assert len(layout_nest.RelatedObjects) == 2
|
||||
|
||||
referent_nest = ifcopenshell.api.alignment.get_referent_nest(file, alignment)
|
||||
assert len(referent_nest.RelatedObjects) == 1
|
||||
stationing_nest = ifcopenshell.api.alignment.get_stationing_nest(file, alignment)
|
||||
assert len(stationing_nest.RelatedObjects) == 1
|
||||
|
||||
segment_nest = ifcopenshell.api.alignment.get_alignment_segment_nest(vlayout)
|
||||
assert len(segment_nest.RelatedObjects) == 3
|
||||
|
||||
Reference in New Issue
Block a user