mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
black .
This commit is contained in:
+7
-4
@@ -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
|
||||
|
||||
@@ -69,4 +69,3 @@ def test_create():
|
||||
assert ifcopenshell.api.alignment.has_zero_length_segment(
|
||||
a
|
||||
) # there is a check in this function for the geometry curve
|
||||
|
||||
|
||||
@@ -28,23 +28,22 @@ def test_create_as_polyline():
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
|
||||
points = [
|
||||
file.createIfcCartesianPoint((945.2, 583.6, 50.0)),
|
||||
file.createIfcCartesianPoint((756.3, 871.7, 66.2)),
|
||||
file.createIfcCartesianPoint(( 567.4, 1159.7, 78.5)),
|
||||
file.createIfcCartesianPoint(( 379.4, 1448.3, 86.8)),
|
||||
file.createIfcCartesianPoint(( 201.7, 1743.3, 91.1)),
|
||||
file.createIfcCartesianPoint(( 36.8, 2045.7, 91.3)),
|
||||
file.createIfcCartesianPoint((-118.9, 2353.0, 87.5)),
|
||||
file.createIfcCartesianPoint((-274.3, 2660.4, 79.7)),
|
||||
file.createIfcCartesianPoint((-429.6, 2967.8, 68.3)),
|
||||
file.createIfcCartesianPoint((-585.0, 3275.2, 56.2 )),
|
||||
]
|
||||
file.createIfcCartesianPoint((945.2, 583.6, 50.0)),
|
||||
file.createIfcCartesianPoint((756.3, 871.7, 66.2)),
|
||||
file.createIfcCartesianPoint((567.4, 1159.7, 78.5)),
|
||||
file.createIfcCartesianPoint((379.4, 1448.3, 86.8)),
|
||||
file.createIfcCartesianPoint((201.7, 1743.3, 91.1)),
|
||||
file.createIfcCartesianPoint((36.8, 2045.7, 91.3)),
|
||||
file.createIfcCartesianPoint((-118.9, 2353.0, 87.5)),
|
||||
file.createIfcCartesianPoint((-274.3, 2660.4, 79.7)),
|
||||
file.createIfcCartesianPoint((-429.6, 2967.8, 68.3)),
|
||||
file.createIfcCartesianPoint((-585.0, 3275.2, 56.2)),
|
||||
]
|
||||
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_as_polyline(file,"A1",points)
|
||||
alignment = ifcopenshell.api.alignment.create_as_polyline(file, "A1", points)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcPolyline")
|
||||
assert len(curve.Points) == 10
|
||||
|
||||
|
||||
test_create_as_polyline()
|
||||
test_create_as_polyline()
|
||||
|
||||
Reference in New Issue
Block a user