This commit is contained in:
Andrej730
2025-07-14 16:29:07 +05:00
parent 73b76ba666
commit 72af88a4b3
6 changed files with 29 additions and 32 deletions
@@ -25,7 +25,9 @@ import math
from collections.abc import Sequence
def _create_polyline_representation(file: ifcopenshell.file, alignment: entity_instance, points: Sequence[Sequence[float]]) -> None:
def _create_polyline_representation(
file: ifcopenshell.file, alignment: entity_instance, points: Sequence[Sequence[float]]
) -> None:
"""
Create geometric representation for the alignment based on an IfcPolyline
@@ -40,9 +42,11 @@ def _create_polyline_representation(file: ifcopenshell.file, alignment: entity_i
placement = file.createIfcLocalPlacement(
PlacementRelTo=None,
RelativePlacement=file.createIfcAxis2Placement3D(Location=file.createIfcCartesianPoint(Coordinates=(0.0, 0.0, 0.0))),
RelativePlacement=file.createIfcAxis2Placement3D(
Location=file.createIfcCartesianPoint(Coordinates=(0.0, 0.0, 0.0))
),
)
curve = file.createIfcPolyLine(Points=points)
representation = file.createIfcShapeRepresentation(
@@ -52,6 +56,5 @@ def _create_polyline_representation(file: ifcopenshell.file, alignment: entity_i
Items=(curve,),
)
alignment.ObjectPlacement = placement
ifcopenshell.api.geometry.assign_representation(file, alignment, representation)
@@ -102,11 +102,11 @@ def add_stationing_referent(
ay = float(p[1, 2])
az = float(p[2, 2])
object_placement.CartesianPosition=file.createIfcAxis2Placement3D(
Location=file.createIfcCartesianPoint((x, y, z)),
Axis=file.createIfcDirection((ax, ay, az)),
RefDirection=file.createIfcDirection((rx, ry, rz)),
)
object_placement.CartesianPosition = file.createIfcAxis2Placement3D(
Location=file.createIfcCartesianPoint((x, y, z)),
Axis=file.createIfcDirection((ax, ay, az)),
RefDirection=file.createIfcDirection((rx, ry, rz)),
)
# this commented out code is what you would do to add a geometric representation of the referent
# the example is a circle. a better way would be to pass a representation into the function
# representation = file.create_entity(
@@ -77,9 +77,7 @@ def create(
# define stationing
name = ifcopenshell.util.stationing.station_as_string(file, start_station)
referent = ifcopenshell.api.alignment.add_stationing_referent(
file, alignment, 0.0, start_station, name
)
referent = ifcopenshell.api.alignment.add_stationing_referent(file, alignment, 0.0, start_station, name)
ifcopenshell.api.nest.reorder_nesting(file, referent, -1, 0)
# IFC 4.1.4.1.1 Alignment Aggregation To Project
@@ -87,4 +85,4 @@ def create(
if project:
ifcopenshell.api.aggregate.assign_object(file, products=[alignment], relating_object=project)
return alignment
return alignment
@@ -55,9 +55,7 @@ def create_as_polyline(
# define stationing
name = ifcopenshell.util.stationing.station_as_string(file, start_station)
referent = ifcopenshell.api.alignment.add_stationing_referent(
file, alignment, 0.0, start_station, name
)
referent = ifcopenshell.api.alignment.add_stationing_referent(file, alignment, 0.0, start_station, name)
ifcopenshell.api.nest.reorder_nesting(file, referent, -1, 0)
# IFC 4.1.4.1.1 Alignment Aggregation To Project
@@ -65,4 +63,4 @@ def create_as_polyline(
if project:
ifcopenshell.api.aggregate.assign_object(file, products=[alignment], relating_object=project)
return alignment
return alignment