mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Fixes problems with referents
This commit is contained in:
@@ -34,6 +34,7 @@ def add_stationing_referent(
|
||||
distance_along: float,
|
||||
station: float,
|
||||
name: str,
|
||||
positioned_product: entity_instance
|
||||
) -> entity_instance:
|
||||
"""
|
||||
Adds an IfcReferent to the element with the Pset_Stationing property set.
|
||||
@@ -43,6 +44,7 @@ def add_stationing_referent(
|
||||
:param distance_along: distance along the alignment curve
|
||||
:param station: station value
|
||||
:param name: name to assign to IfcReferent.Name, typically a stringized version of the station value
|
||||
:param positioned_product: the product whose position is informed by the referent
|
||||
:return: referent
|
||||
|
||||
Example:
|
||||
@@ -54,9 +56,17 @@ def add_stationing_referent(
|
||||
"""
|
||||
alignment = element
|
||||
|
||||
layout_types = [
|
||||
"IfcAlignmentHorizontal",
|
||||
"IfcAlignmentVertical",
|
||||
"IfcAlignmentCant",
|
||||
]
|
||||
|
||||
if element.is_a("IfcAlignmentSegment"):
|
||||
layout = element.Nests[0].RelatingObject
|
||||
alignment = ifcopenshell.api.alignment.get_alignment(layout)
|
||||
elif element.is_a() in layout_types:
|
||||
alignment = ifcopenshell.api.alignment.get_alignment(element)
|
||||
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
|
||||
@@ -137,15 +147,15 @@ def add_stationing_referent(
|
||||
nest = ifcopenshell.api.alignment.get_referent_nest(file,element)
|
||||
nest.RelatedObjects += (referent,)
|
||||
|
||||
if len(alignment.Positions) == 0:
|
||||
if len(referent.Positions) == 0:
|
||||
rel_positions = file.createIfcRelPositions(
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatingPositioningElement=alignment,
|
||||
RelatingPositioningElement=referent,
|
||||
RelatedProducts=[
|
||||
referent,
|
||||
positioned_product,
|
||||
],
|
||||
)
|
||||
else:
|
||||
alignment.Positions[0].RelatedProducts += (referent,)
|
||||
referent.Positions[0].RelatedProducts += (positioned_product,)
|
||||
|
||||
return referent
|
||||
|
||||
Reference in New Issue
Block a user