This commit is contained in:
Andrej730
2025-05-13 11:45:11 +05:00
parent 7c38705958
commit f8799305e1
2 changed files with 17 additions and 15 deletions
@@ -23,7 +23,9 @@ import ifcopenshell.guid
from ifcopenshell import entity_instance from ifcopenshell import entity_instance
def add_stationing_to_alignment(file: ifcopenshell.file, alignment: entity_instance, start_station: float, plus_seperator=3,accuracy=3) -> None: def add_stationing_to_alignment(
file: ifcopenshell.file, alignment: entity_instance, start_station: float, plus_seperator=3, accuracy=3
) -> None:
""" """
Adds stationing to an alignment by creating an IfcReferent with the Pset_Stationing property set to establish the stationing at the start of the alignment. Adds stationing to an alignment by creating an IfcReferent with the Pset_Stationing property set to establish the stationing at the start of the alignment.
Note - this function assumes the stationing has not been previously defined Note - this function assumes the stationing has not been previously defined
@@ -45,18 +47,18 @@ def add_stationing_to_alignment(file: ifcopenshell.file, alignment: entity_insta
representation = None representation = None
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment) basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
if basis_curve: if basis_curve:
object_placement = file.createIfcLinearPlacement( object_placement = file.createIfcLinearPlacement(
RelativePlacement=file.createIfcAxis2PlacementLinear( RelativePlacement=file.createIfcAxis2PlacementLinear(
Location=file.createIfcPointByDistanceExpression( Location=file.createIfcPointByDistanceExpression(
DistanceAlong=file.createIfcLengthMeasure(0.0), DistanceAlong=file.createIfcLengthMeasure(0.0),
OffsetLateral=None, OffsetLateral=None,
OffsetVertical=None, OffsetVertical=None,
OffsetLongitudinal=None, OffsetLongitudinal=None,
BasisCurve=basis_curve, BasisCurve=basis_curve,
) )
), ),
CartesianPosition=None, CartesianPosition=None,
) )
# representation = file.create_entity( # representation = file.create_entity(
# name="IfcCircle", # name="IfcCircle",
# position=file.createIfcAxis2Placement2D(Location=file.createIfcCartesianPoint(Coordinates=(0.0, 0.0)), # position=file.createIfcAxis2Placement2D(Location=file.createIfcCartesianPoint(Coordinates=(0.0, 0.0)),
@@ -67,7 +69,7 @@ def add_stationing_to_alignment(file: ifcopenshell.file, alignment: entity_insta
start_referent = file.createIfcReferent( start_referent = file.createIfcReferent(
GlobalId=ifcopenshell.guid.new(), GlobalId=ifcopenshell.guid.new(),
OwnerHistory=None, OwnerHistory=None,
Name=ifcopenshell.util.stationing.station_as_string(start_station,plus_seperator,accuracy), Name=ifcopenshell.util.stationing.station_as_string(start_station, plus_seperator, accuracy),
Description=None, Description=None,
ObjectType=None, ObjectType=None,
ObjectPlacement=object_placement, ObjectPlacement=object_placement,
@@ -55,4 +55,4 @@ def test_add_stationing_to_alignment():
ifcopenshell.util.element.get_pset(element=referent, name="Pset_Stationing", prop="Station") ifcopenshell.util.element.get_pset(element=referent, name="Pset_Stationing", prop="Station")
== 2000.0 == 2000.0
) )
assert(referent.ObjectPlacement != None) assert referent.ObjectPlacement != None