mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
black .
This commit is contained in:
@@ -20,7 +20,10 @@ import ifcopenshell
|
||||
from ifcopenshell import entity_instance
|
||||
import typing
|
||||
|
||||
def add_survey_point(file: ifcopenshell.file, survey_point: entity_instance, site:entity_instance = None) -> entity_instance:
|
||||
|
||||
def add_survey_point(
|
||||
file: ifcopenshell.file, survey_point: entity_instance, site: entity_instance = None
|
||||
) -> entity_instance:
|
||||
"""
|
||||
Adds a single survey point to the model based on IFC Concept Template 4.1.7.1.2.5.
|
||||
Survey points are located relative to IfcRepresentationContext.WorldCoordinateSystem
|
||||
@@ -34,14 +37,21 @@ def add_survey_point(file: ifcopenshell.file, survey_point: entity_instance, sit
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint(4000.0,3500.0)))
|
||||
"""
|
||||
context = ifcopenshell.util.representation.get_context(file,"Model","Annotation","MODEL_VIEW")
|
||||
shape_representation = file.createIfcShapeRepresentation(ContextOfItems=context,RepresentationIdentifier='Annotation',RepresentationType='Point',Items=[survey_point])
|
||||
context = ifcopenshell.util.representation.get_context(file, "Model", "Annotation", "MODEL_VIEW")
|
||||
shape_representation = file.createIfcShapeRepresentation(
|
||||
ContextOfItems=context, RepresentationIdentifier="Annotation", RepresentationType="Point", Items=[survey_point]
|
||||
)
|
||||
representation = file.createIfcProductDefinitionShape(Representations=[shape_representation])
|
||||
annotation = file.createIfcAnnotation(ifcopenshell.guid.new(),ObjectPlacement=context.WorldCoordinateSystem,Representation=representation,PredefinedType="SURVEY")
|
||||
|
||||
if (site == None):
|
||||
annotation = file.createIfcAnnotation(
|
||||
ifcopenshell.guid.new(),
|
||||
ObjectPlacement=context.WorldCoordinateSystem,
|
||||
Representation=representation,
|
||||
PredefinedType="SURVEY",
|
||||
)
|
||||
|
||||
if site == None:
|
||||
site = file.by_type("IfcSite")[0]
|
||||
|
||||
ifcopenshell.api.spatial.assign_container(file,relating_structure=site,products=[annotation])
|
||||
ifcopenshell.api.spatial.assign_container(file, relating_structure=site, products=[annotation])
|
||||
|
||||
return annotation
|
||||
|
||||
@@ -20,6 +20,7 @@ import ifcopenshell
|
||||
from ifcopenshell import entity_instance
|
||||
import typing
|
||||
|
||||
|
||||
def assign_survey_point(annotation: entity_instance, survey_point: entity_instance):
|
||||
"""
|
||||
Assigns a coordinate point to a survey point annotation
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
import ifcopenshell.util.geolocation
|
||||
|
||||
def bearing2dd(bearing: str)->float:
|
||||
|
||||
def bearing2dd(bearing: str) -> float:
|
||||
"""
|
||||
Converts a quadrant bearing string to decimal degrees
|
||||
|
||||
@@ -35,26 +36,26 @@ def bearing2dd(bearing: str)->float:
|
||||
"""
|
||||
error_msg = "Invalid bearing string"
|
||||
|
||||
bearing = bearing.strip() # trim external white space
|
||||
bearing = ' '.join(bearing.split()) # make sure all parts separated by a single space
|
||||
bearing = bearing.strip() # trim external white space
|
||||
bearing = " ".join(bearing.split()) # make sure all parts separated by a single space
|
||||
parts = bearing.split()
|
||||
nParts = len(parts)
|
||||
if nParts < 3 or 5 < nParts:
|
||||
raise ValueError(error_msg)
|
||||
|
||||
|
||||
cY = parts[0]
|
||||
cY = cY.upper()
|
||||
if cY != 'N' and cY != 'S':
|
||||
if cY != "N" and cY != "S":
|
||||
raise ValueError(error_msg)
|
||||
|
||||
cX = parts[-1]
|
||||
cX = cX.upper()
|
||||
if cX != 'E' and cX != 'W':
|
||||
if cX != "E" and cX != "W":
|
||||
raise ValueError(error_msg)
|
||||
|
||||
|
||||
d = 0
|
||||
m = 0
|
||||
s = 0.
|
||||
s = 0.0
|
||||
ms = 0
|
||||
|
||||
if nParts == 3:
|
||||
@@ -69,38 +70,37 @@ def bearing2dd(bearing: str)->float:
|
||||
|
||||
# s in a decimal number
|
||||
# need to break it into whole seconds and milliseconds
|
||||
ms = 100.*(s - int(s))
|
||||
ms = 100.0 * (s - int(s))
|
||||
s = int(s)
|
||||
|
||||
if d < 0 or (m < 0 or 60 <= m) or (s < 0 or 60 <= s) or ms < 0:
|
||||
raise ValueError(error_msg)
|
||||
|
||||
if cY == 'N' and cX == 'E':
|
||||
angle = 90.
|
||||
sign = -1.
|
||||
elif cY == 'N' and cX == 'W':
|
||||
angle = 90.
|
||||
sign = 1.
|
||||
elif cY == 'S' and cX == 'E':
|
||||
angle = 270.
|
||||
sign = 1.
|
||||
elif cY == 'S' and cX == 'W':
|
||||
angle = 270.
|
||||
sign = -1.
|
||||
|
||||
if cY == "N" and cX == "E":
|
||||
angle = 90.0
|
||||
sign = -1.0
|
||||
elif cY == "N" and cX == "W":
|
||||
angle = 90.0
|
||||
sign = 1.0
|
||||
elif cY == "S" and cX == "E":
|
||||
angle = 270.0
|
||||
sign = 1.0
|
||||
elif cY == "S" and cX == "W":
|
||||
angle = 270.0
|
||||
sign = -1.0
|
||||
|
||||
try:
|
||||
dms = ifcopenshell.util.geolocation.dms2dd(d,m,s,ms)
|
||||
dms = ifcopenshell.util.geolocation.dms2dd(d, m, s, ms)
|
||||
except ValueError:
|
||||
raise ValueError(error_msg)
|
||||
|
||||
if dms < 0. or 90. < dms:
|
||||
|
||||
if dms < 0.0 or 90.0 < dms:
|
||||
raise ValueError(error_msg)
|
||||
|
||||
angle += sign*dms
|
||||
angle += sign * dms
|
||||
|
||||
# S 90 E will evaluate to 360
|
||||
if angle == 360.:
|
||||
angle = 0.
|
||||
if angle == 360.0:
|
||||
angle = 0.0
|
||||
|
||||
return angle
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ import ifcopenshell
|
||||
from ifcopenshell import entity_instance
|
||||
import typing
|
||||
|
||||
def edit_survey_point(annotation: entity_instance, x:float,y:float,z:float=0.0):
|
||||
|
||||
def edit_survey_point(annotation: entity_instance, x: float, y: float, z: float = 0.0):
|
||||
"""
|
||||
Edits the location of a previously defined survey point
|
||||
|
||||
@@ -35,6 +36,6 @@ def edit_survey_point(annotation: entity_instance, x:float,y:float,z:float=0.0):
|
||||
ifcopenshell.api.cogo.edit_surve_point(annotation,3500.0,2000.0)
|
||||
"""
|
||||
if annotation.Representation.Representations[0].Items[0].Dim == 2:
|
||||
annotation.Representation.Representations[0].Items[0].Coordinates = ((x,y))
|
||||
annotation.Representation.Representations[0].Items[0].Coordinates = (x, y)
|
||||
else:
|
||||
annotation.Representation.Representations[0].Items[0].Coordinates = ((x,y,z))
|
||||
annotation.Representation.Representations[0].Items[0].Coordinates = (x, y, z)
|
||||
|
||||
@@ -20,6 +20,7 @@ import math
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.unit
|
||||
|
||||
|
||||
def station_as_string(file: ifcopenshell.file, sta: float):
|
||||
"""
|
||||
Returns a stringized version of a station. Example 100.0 is 1+00.00 as a stationing string.
|
||||
@@ -28,18 +29,21 @@ def station_as_string(file: ifcopenshell.file, sta: float):
|
||||
:param station: the station to be stringized
|
||||
:return: stringized station
|
||||
"""
|
||||
|
||||
unit_type = ifcopenshell.util.unit.get_project_unit(file,"LENGTHUNIT")
|
||||
|
||||
unit_type = ifcopenshell.util.unit.get_project_unit(file, "LENGTHUNIT")
|
||||
if unit_type.is_a("IfcConversionBasedUnit"):
|
||||
station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=None,to_unit="foot",to_prefix=None)
|
||||
station = ifcopenshell.util.unit.convert(
|
||||
sta, from_unit=unit_type.Name, from_prefix=None, to_unit="foot", to_prefix=None
|
||||
)
|
||||
plus_seperator = 2
|
||||
precision = 2
|
||||
else:
|
||||
station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=unit_type.Prefix,to_unit="meter",to_prefix=None)
|
||||
station = ifcopenshell.util.unit.convert(
|
||||
sta, from_unit=unit_type.Name, from_prefix=unit_type.Prefix, to_unit="meter", to_prefix=None
|
||||
)
|
||||
plus_seperator = 3
|
||||
precision = 3
|
||||
|
||||
|
||||
value = math.fabs(station)
|
||||
|
||||
shifter = math.pow(10.0, plus_seperator)
|
||||
@@ -48,7 +52,7 @@ def station_as_string(file: ifcopenshell.file, sta: float):
|
||||
|
||||
# Check to make sure that v2 is not basically the same as shifter
|
||||
# If station = 69500.00000, we sometimes get 694+100.00 instead of 695+00.00
|
||||
if math.isclose(v2-shifter, 0., abs_tol=5.0 * math.pow(10.0, -(precision + 1))):
|
||||
if math.isclose(v2 - shifter, 0.0, abs_tol=5.0 * math.pow(10.0, -(precision + 1))):
|
||||
v2 = 0.0
|
||||
v1 += 1
|
||||
|
||||
|
||||
@@ -22,11 +22,12 @@ import ifcopenshell.api.context
|
||||
|
||||
from ifcopenshell.api.alignment._add_segment_to_layout import _add_segment_to_layout
|
||||
|
||||
|
||||
def test_add_segment_to_layout():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,7 +37,7 @@ def test_add_segment_to_layout():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"")
|
||||
alignment = ifcopenshell.api.alignment.create(file, "")
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
|
||||
design_parameters = file.create_entity(
|
||||
@@ -66,6 +67,10 @@ def test_add_segment_to_layout():
|
||||
_add_segment_to_layout(file, horizontal_alignment, alignment_segment)
|
||||
|
||||
assert len(horizontal_alignment.IsNestedBy) == 1
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2 # The the segment we added and the automatically created zero length segment
|
||||
assert (
|
||||
len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
) # The the segment we added and the automatically created zero length segment
|
||||
assert horizontal_alignment.IsNestedBy[0].RelatedObjects[0] == alignment_segment
|
||||
assert alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent") # a referent is automatically added at the start of the segment
|
||||
assert (
|
||||
alignment_segment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
) # a referent is automatically added at the start of the segment
|
||||
|
||||
@@ -21,11 +21,12 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def test_add_stationing_to_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,9 +36,7 @@ def test_add_stationing_to_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", start_station=2000.
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", start_station=2000.0)
|
||||
|
||||
for rel in alignment.IsNestedBy:
|
||||
for referent in rel.RelatedObjects:
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_add_vertical_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,7 +35,7 @@ def test_add_vertical_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"A1",include_vertical=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "A1", include_vertical=False)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
@@ -45,11 +45,13 @@ def test_add_vertical_alignment():
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment)
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
@@ -57,7 +59,7 @@ def test_add_vertical_alignment():
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
# add a second vertical alignment
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file,alignment)
|
||||
vertical_layout = ifcopenshell.api.alignment.add_vertical_layout(file, alignment)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 1 # 1 IfcRelAggreates relationship for the child algiments
|
||||
assert (
|
||||
@@ -75,4 +77,5 @@ def test_add_vertical_alignment():
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
|
||||
test_add_vertical_alignment()
|
||||
|
||||
test_add_vertical_alignment()
|
||||
|
||||
@@ -24,9 +24,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_create_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,34 +36,36 @@ def test_create_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
include_vertical = [False,True,True]
|
||||
include_vertical = [False, True, True]
|
||||
include_cant = [False, False, True]
|
||||
expected_curve_type = ["IfcCompositeCurve","IfcGradientCurve","IfcSegmentedReferenceCurve"]
|
||||
expected_curve_type = ["IfcCompositeCurve", "IfcGradientCurve", "IfcSegmentedReferenceCurve"]
|
||||
|
||||
for i in range(0,3) :
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i])
|
||||
for i in range(0, 3):
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i])
|
||||
assert ali != None
|
||||
|
||||
# verify the geometric representation was created
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert(curve.is_a() == expected_curve_type[i])
|
||||
assert curve.is_a() == expected_curve_type[i]
|
||||
assert len(curve.Segments) == 1
|
||||
|
||||
horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
vert = ifcopenshell.api.alignment.get_vertical_layout(ali)
|
||||
cant = ifcopenshell.api.alignment.get_cant_layout(ali)
|
||||
|
||||
|
||||
assert horiz != None
|
||||
if include_vertical[i]:
|
||||
assert vert != None
|
||||
|
||||
|
||||
if include_cant[i]:
|
||||
assert cant != None
|
||||
|
||||
# verify each layout has a zero length segment (which also tests if the geometry curve has a zero length segment)
|
||||
alignments = [horiz,vert,cant]
|
||||
alignments = [horiz, vert, cant]
|
||||
for a in alignments:
|
||||
if a != None:
|
||||
segments = ifcopenshell.api.alignment.get_layout_segments(a)
|
||||
assert len(segments) == 1
|
||||
assert ifcopenshell.api.alignment.has_zero_length_segment(a) # there is a check in this function for the geometry curve
|
||||
assert ifcopenshell.api.alignment.has_zero_length_segment(
|
||||
a
|
||||
) # there is a check in this function for the geometry curve
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_create_alignment_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -40,18 +40,27 @@ def test_create_alignment_pi_method():
|
||||
vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)]
|
||||
lengths = [(1600.0), (1200.0), (2000.0), (800.0)]
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints, lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8 # segments in horizontal layout
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10 # segments in vertical layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 8
|
||||
) # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 10
|
||||
) # segments in vertical layout
|
||||
|
||||
test_create_alignment_pi_method()
|
||||
|
||||
test_create_alignment_pi_method()
|
||||
|
||||
@@ -22,11 +22,12 @@ import ifcopenshell.api.context
|
||||
from ifcopenshell import entity_instance
|
||||
import math
|
||||
|
||||
|
||||
def _test_horizontal() -> ifcopenshell.file:
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -37,13 +38,13 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
)
|
||||
|
||||
# creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1")
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1")
|
||||
|
||||
# append a segment to the horizontal layout
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(horizontal_alignment)
|
||||
assert curve == None # for single horizontal, geometric representation is on IfcAlignment
|
||||
assert curve == None # for single horizontal, geometric representation is on IfcAlignment
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
assert len(curve.Segments) == 1
|
||||
@@ -60,14 +61,14 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
GravityCenterLineHeight=None,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 0.0
|
||||
assert z == 0.0
|
||||
@@ -76,13 +77,12 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
assert len(curve.Segments) == 2
|
||||
|
||||
|
||||
design_parameters = file.create_entity(
|
||||
type="IfcAlignmentHorizontalSegment",
|
||||
StartTag=None,
|
||||
EndTag=None,
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((x.item(), y.item()))),
|
||||
StartDirection=math.pi/6,
|
||||
StartDirection=math.pi / 6,
|
||||
StartRadiusOfCurvature=0.0,
|
||||
EndRadiusOfCurvature=0.0,
|
||||
SegmentLength=50.0,
|
||||
@@ -90,15 +90,15 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
assert len(horizontal_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.0 + 50.0*math.cos(math.pi/6)
|
||||
assert y == 50.0*math.sin(math.pi/6)
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0 + 50.0 * math.cos(math.pi / 6)
|
||||
assert y == 50.0 * math.sin(math.pi / 6)
|
||||
assert z == 0.0
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
@@ -110,9 +110,9 @@ def _test_horizontal() -> ifcopenshell.file:
|
||||
|
||||
def _test_horizontal_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -123,7 +123,7 @@ def _test_horizontal_vertical():
|
||||
)
|
||||
|
||||
# creates an IfcAlignment with an IfcAlignmentHorizontal layout containing only the zero length segment
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",True)
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", True)
|
||||
|
||||
# append a segment to the horizontal layout
|
||||
horizontal_alignment = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
@@ -154,53 +154,53 @@ def _test_horizontal_vertical():
|
||||
GravityCenterLineHeight=None,
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,horizontal_alignment,design_parameters)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, horizontal_alignment, design_parameters)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
assert len(basis_curve.Segments) == 2
|
||||
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=20.0,
|
||||
StartGradient = 1./100.,
|
||||
EndGradient = 1./100.,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=1.0 / 100.0,
|
||||
EndGradient=1.0 / 100.0,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 50.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 50.0
|
||||
assert y == 20.5
|
||||
assert z == 0.0
|
||||
|
||||
dx = end[0,0]
|
||||
dy = end[1,0]
|
||||
gradient = dy/dx
|
||||
dx = end[0, 0]
|
||||
dy = end[1, 0]
|
||||
gradient = dy / dx
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=50.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=y.item(),
|
||||
StartGradient = -gradient,
|
||||
EndGradient = -gradient,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=-gradient,
|
||||
EndGradient=-gradient,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.
|
||||
assert y == 20.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 20.0
|
||||
assert z == 0.0
|
||||
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(ali)
|
||||
@@ -216,60 +216,62 @@ def _test_horizontal_vertical2(file: ifcopenshell.file):
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.get_vertical_layout(ali)
|
||||
assert vertical_alignment == None
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file,ali)
|
||||
|
||||
vertical_alignment = ifcopenshell.api.alignment.add_vertical_layout(file, ali)
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=20.0,
|
||||
StartGradient = 1./100.,
|
||||
EndGradient = 1./100.,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=1.0 / 100.0,
|
||||
EndGradient=1.0 / 100.0,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 2
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 50.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 50.0
|
||||
assert y == 20.5
|
||||
assert z == 0.0
|
||||
|
||||
dx = end[0,0]
|
||||
dy = end[1,0]
|
||||
gradient = dy/dx
|
||||
dx = end[0, 0]
|
||||
dy = end[1, 0]
|
||||
gradient = dy / dx
|
||||
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=50.0,
|
||||
HorizontalLength=50.0,
|
||||
StartHeight=y.item(),
|
||||
StartGradient = -gradient,
|
||||
EndGradient = -gradient,
|
||||
PredefinedType="CONSTANTGRADIENT"
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file,vertical_alignment,design_parameters)
|
||||
StartGradient=-gradient,
|
||||
EndGradient=-gradient,
|
||||
PredefinedType="CONSTANTGRADIENT",
|
||||
)
|
||||
end = ifcopenshell.api.alignment.create_layout_segment(file, vertical_alignment, design_parameters)
|
||||
|
||||
assert len(vertical_alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
|
||||
x = end[0,3]
|
||||
y = end[1,3]
|
||||
z = end[2,3]
|
||||
|
||||
assert x == 100.
|
||||
assert y == 20.
|
||||
x = end[0, 3]
|
||||
y = end[1, 3]
|
||||
z = end[2, 3]
|
||||
|
||||
assert x == 100.0
|
||||
assert y == 20.0
|
||||
assert z == 0.0
|
||||
|
||||
curve = ifcopenshell.api.alignment.get_curve(ali)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
assert len(curve.Segments) == 3
|
||||
|
||||
|
||||
def test_append_segment():
|
||||
file = _test_horizontal()
|
||||
_test_horizontal_vertical()
|
||||
_test_horizontal_vertical2(file)
|
||||
|
||||
test_append_segment()
|
||||
|
||||
test_append_segment()
|
||||
|
||||
@@ -20,11 +20,12 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def test_distance_along_from_station():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -40,7 +41,7 @@ def test_distance_along_from_station():
|
||||
lengths = [(1600.0), (1200.0), (2000.0), (800.0)]
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths,start_station=10000.0
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths, start_station=10000.0
|
||||
)
|
||||
|
||||
# Station 138+83.96
|
||||
@@ -50,4 +51,4 @@ def test_distance_along_from_station():
|
||||
assert ifcopenshell.api.alignment.distance_along_from_station(file, alignment, 17525.36) == pytest.approx(7525.36)
|
||||
|
||||
|
||||
test_distance_along_from_station()
|
||||
test_distance_along_from_station()
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_get_alignment():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -35,11 +35,11 @@ def test_get_alignment():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
include_vertical = [False,True,True]
|
||||
include_vertical = [False, True, True]
|
||||
include_cant = [False, False, True]
|
||||
|
||||
for i in range(0,3) :
|
||||
ali = ifcopenshell.api.alignment.create(file,"A1",include_vertical[i],include_cant[i])
|
||||
for i in range(0, 3):
|
||||
ali = ifcopenshell.api.alignment.create(file, "A1", include_vertical[i], include_cant[i])
|
||||
assert ali != None
|
||||
|
||||
horiz = ifcopenshell.api.alignment.get_horizontal_layout(ali)
|
||||
@@ -49,6 +49,6 @@ def test_get_alignment():
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(horiz)
|
||||
if include_vertical[i]:
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(vert)
|
||||
|
||||
|
||||
if include_cant[i]:
|
||||
assert ali == ifcopenshell.api.alignment.get_alignment(cant)
|
||||
|
||||
@@ -24,9 +24,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def _test_horizontal():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -43,9 +43,9 @@ def _test_horizontal():
|
||||
|
||||
def _test_horizontal_and_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -55,17 +55,16 @@ def _test_horizontal_and_vertical():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", include_vertical=True
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
|
||||
|
||||
def _test_horizontal_and_vertical_and_cant():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -75,12 +74,11 @@ def _test_horizontal_and_vertical_and_cant():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(
|
||||
file, "TestAlignment", include_vertical=True,include_cant=True
|
||||
)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
basis_curve = ifcopenshell.api.alignment.get_basis_curve(alignment)
|
||||
assert basis_curve.is_a("IfcCompositeCurve")
|
||||
|
||||
|
||||
def test_get_basis_curve():
|
||||
_test_horizontal()
|
||||
_test_horizontal_and_vertical()
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
|
||||
def test_get_curve():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -32,14 +33,14 @@ def test_get_curve():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
curve = ifcopenshell.api.alignment.get_curve(alignment)
|
||||
assert curve.is_a("IfcSegmentedReferenceCurve")
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
import ifcopenshell.api.alignment
|
||||
|
||||
|
||||
def test_get_layout_curve():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -32,12 +33,12 @@ def test_get_layout_curve():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=False,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=False)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
@@ -45,7 +46,7 @@ def test_get_layout_curve():
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcGradientCurve")
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
||||
assert curve.is_a("IfcCompositeCurve")
|
||||
|
||||
@@ -20,11 +20,12 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.alignment.has_zero_length_segment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def _test_horizontal():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -34,15 +35,16 @@ def _test_horizontal():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment")
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment")
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
|
||||
|
||||
def _test_horizontal_vertical():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -52,17 +54,18 @@ def _test_horizontal_vertical():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(vertical)
|
||||
|
||||
|
||||
def _test_horizontal_vertical_cant():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -72,7 +75,7 @@ def _test_horizontal_vertical_cant():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file,"TestAlignment",include_vertical=True,include_cant=True)
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
||||
horizontal = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(horizontal)
|
||||
vertical = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
@@ -80,10 +83,11 @@ def _test_horizontal_vertical_cant():
|
||||
cant = ifcopenshell.api.alignment.get_cant_layout(alignment)
|
||||
assert True == ifcopenshell.api.alignment.has_zero_length_segment(cant)
|
||||
|
||||
|
||||
def test_has_zero_length_segment():
|
||||
_test_horizontal()
|
||||
_test_horizontal_vertical()
|
||||
_test_horizontal_vertical_cant()
|
||||
|
||||
|
||||
test_has_zero_length_segment()
|
||||
test_has_zero_length_segment()
|
||||
|
||||
@@ -20,14 +20,15 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
# other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method)
|
||||
# this test will focus on the edge cases of no initial tangent run, no final tangent run, and
|
||||
# compound curve (no tangent between curves)
|
||||
def test_horizontal_layout_by_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -50,6 +51,9 @@ def test_horizontal_layout_by_pi_method():
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3 # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 3
|
||||
) # segments in horizontal layout
|
||||
|
||||
test_horizontal_layout_by_pi_method()
|
||||
|
||||
test_horizontal_layout_by_pi_method()
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
from ifcopenshell.api.alignment._map_alignment_cant_segment import _map_alignment_cant_segment
|
||||
|
||||
|
||||
def _BlossCurve_100_0_300_1000_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentCantSegment(
|
||||
StartDistAlong=0.0,
|
||||
|
||||
@@ -23,6 +23,7 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
from ifcopenshell.api.alignment._map_alignment_horizontal_segment import __map_alignment_horizontal_segment
|
||||
|
||||
|
||||
def _BlossCurve_100_0_300_1000_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint((0.0, 0.0)),
|
||||
|
||||
@@ -23,6 +23,7 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
from ifcopenshell.api.alignment._map_alignment_vertical_segment import _map_alignment_vertical_segment
|
||||
|
||||
|
||||
def _CircularArc_100_0_10_0_0_0_0_5_1_Meter(file):
|
||||
design_parameters = file.createIfcAlignmentVerticalSegment(
|
||||
StartDistAlong=0.0,
|
||||
|
||||
@@ -23,9 +23,9 @@ import ifcopenshell.api.context
|
||||
|
||||
def test_name_segments():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
|
||||
@@ -42,8 +42,9 @@ def default_names_alignment():
|
||||
vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)]
|
||||
lengths = [(1600.0), (1200.0), (2000.0), (800.0)]
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints,
|
||||
lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
yield alignment
|
||||
|
||||
|
||||
@@ -88,8 +89,9 @@ def callback_alignment():
|
||||
vpoints = [(0.0, 100.0), (2000.0, 135.0), (5000.0, 105.0), (7400.0, 153.0), (9800.0, 105.0), (12800.0, 90.0)]
|
||||
lengths = [(1600.0), (1200.0), (2000.0), (800.0)]
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(file, "TestAlignment", coordinates, radii, vpoints,
|
||||
lengths)
|
||||
alignment = ifcopenshell.api.alignment.create_by_pi_method(
|
||||
file, "TestAlignment", coordinates, radii, vpoints, lengths
|
||||
)
|
||||
yield alignment
|
||||
|
||||
|
||||
@@ -108,6 +110,7 @@ def test_with_default_names(default_names_alignment):
|
||||
assert "P.V.T." in vlayout.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects[0].Name
|
||||
assert "V.P.O.E." in vlayout.IsNestedBy[0].RelatedObjects[-1].IsNestedBy[0].RelatedObjects[0].Name
|
||||
|
||||
|
||||
def test_with_callbacks(callback_alignment):
|
||||
hlayout = ifcopenshell.api.alignment.get_horizontal_layout(callback_alignment)
|
||||
|
||||
|
||||
+13
-10
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code
|
||||
from ifcopenshell.api.alignment._update_curve_segment_transition_code import _update_curve_segment_transition_code
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
def _test1():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -223,18 +223,20 @@ def _test2():
|
||||
),
|
||||
)
|
||||
|
||||
composite_curve = file.createIfcCompositeCurve(Segments=[line1,clothoid1,circular_arc,clothoid2,line2], SelfIntersect=False)
|
||||
composite_curve = file.createIfcCompositeCurve(
|
||||
Segments=[line1, clothoid1, circular_arc, clothoid2, line2], SelfIntersect=False
|
||||
)
|
||||
|
||||
_update_curve_segment_transition_code(line1,clothoid1)
|
||||
_update_curve_segment_transition_code(line1, clothoid1)
|
||||
assert line1.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(clothoid1,circular_arc)
|
||||
_update_curve_segment_transition_code(clothoid1, circular_arc)
|
||||
assert clothoid1.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(circular_arc,clothoid2)
|
||||
_update_curve_segment_transition_code(circular_arc, clothoid2)
|
||||
assert circular_arc.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
_update_curve_segment_transition_code(clothoid2,line2)
|
||||
_update_curve_segment_transition_code(clothoid2, line2)
|
||||
assert clothoid2.Transition == "CONTSAMEGRADIENTSAMECURVATURE"
|
||||
|
||||
|
||||
@@ -242,4 +244,5 @@ def test_update_curve_segment_transition_code():
|
||||
_test1()
|
||||
_test2()
|
||||
|
||||
test_update_curve_segment_transition_code()
|
||||
|
||||
test_update_curve_segment_transition_code()
|
||||
|
||||
@@ -20,14 +20,15 @@ import pytest
|
||||
import ifcopenshell.api.alignment
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
# other test cases cover the typical vertical by PI method (test_create_alignment_by_pi_method)
|
||||
# this test will focus on the edge cases of no initial gradient, no final gradient, and
|
||||
# compound vertical curve (no gradient between curves)
|
||||
def test_vertical_layout_by_pi_method():
|
||||
file = ifcopenshell.file(schema="IFC4X3")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -37,35 +38,41 @@ def test_vertical_layout_by_pi_method():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
|
||||
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True)
|
||||
hlayout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
||||
segment1 = file.createIfcAlignmentHorizontalSegment(
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((0.,0.))), # Actual coordinate unknown
|
||||
StartPoint=file.createIfcCartesianPoint(Coordinates=((0.0, 0.0))), # Actual coordinate unknown
|
||||
StartDirection=0.0,
|
||||
StartRadiusOfCurvature=0.0,
|
||||
EndRadiusOfCurvature=0.0,
|
||||
SegmentLength=10000.0,
|
||||
PredefinedType = "LINE"
|
||||
PredefinedType="LINE",
|
||||
)
|
||||
|
||||
ifcopenshell.api.alignment.create_layout_segment(file,hlayout,segment1)
|
||||
ifcopenshell.api.alignment.create_layout_segment(file, hlayout, segment1)
|
||||
|
||||
vpoints = [(0.0, 110.0), (400.0, 100.0), (800.0, 115.0), (1300.0, 125.0), (1800.0, 105.0)]
|
||||
lengths = [(800.0), (0.0), (1000.0)]
|
||||
vlayout = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
||||
ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file,vlayout,vpoints,lengths)
|
||||
ifcopenshell.api.alignment.layout_vertical_alignment_by_pi_method(file, vlayout, vpoints, lengths)
|
||||
|
||||
assert len(alignment.IsDecomposedBy) == 0 # no child alignments
|
||||
assert len(alignment.IsNestedBy) == 1 # one nest
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects) == 3 # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects) == 3
|
||||
) # nesting IfcReferent, IfcAlignmentHorizontal, IfcAlignmentVertical
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[0].is_a("IfcReferent")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[1].is_a("IfcAlignmentHorizontal")
|
||||
assert alignment.IsNestedBy[0].RelatedObjects[2].is_a("IfcAlignmentVertical")
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy) == 1
|
||||
) # nesting of segments beneath IfcAlignmentHorizontal
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2 # segments in horizontal layout
|
||||
assert len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3 # segments in vertical layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[1].IsNestedBy[0].RelatedObjects) == 2
|
||||
) # segments in horizontal layout
|
||||
assert (
|
||||
len(alignment.IsNestedBy[0].RelatedObjects[2].IsNestedBy[0].RelatedObjects) == 3
|
||||
) # segments in vertical layout
|
||||
|
||||
test_vertical_layout_by_pi_method()
|
||||
|
||||
test_vertical_layout_by_pi_method()
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_add_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,10 +36,9 @@ def test_add_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_assign_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,13 +36,12 @@ def test_assign_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
ifcopenshell.api.cogo.assign_survey_point(annotation,file.createIfcCartesianPoint((20.0,30.0,40.0)))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0,40.0))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
ifcopenshell.api.cogo.assign_survey_point(annotation, file.createIfcCartesianPoint((20.0, 30.0, 40.0)))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0, 40.0))
|
||||
|
||||
@@ -35,39 +35,39 @@ def test_bearing2dd():
|
||||
assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 E"))
|
||||
assert 0.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 E"))
|
||||
|
||||
assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W"))
|
||||
assert 180. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W"))
|
||||
|
||||
assert 120. == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W"))
|
||||
assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 90 W"))
|
||||
assert 180.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("S 90 W"))
|
||||
|
||||
assert 120.0 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 W"))
|
||||
assert 120.16666666666667 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 30 10 W"))
|
||||
|
||||
assert 89.999722222222228 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1 E"))
|
||||
assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 0 0 1 E"))
|
||||
assert 89.99972222222222 == pytest.approx(ifcopenshell.api.cogo.bearing2dd("N 00 00 1.0 E"))
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("Bad String")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("Very Bad String")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 100 15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N -45 15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 -15 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 88 22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 15 -22.5 E")
|
||||
|
||||
with pytest.raises(ValueError,match="Invalid bearing string"):
|
||||
with pytest.raises(ValueError, match="Invalid bearing string"):
|
||||
ifcopenshell.api.cogo.bearing2dd("N 45 15 99.5 E")
|
||||
|
||||
test_bearing2dd()
|
||||
|
||||
test_bearing2dd()
|
||||
|
||||
@@ -25,8 +25,8 @@ import ifcopenshell.api.cogo
|
||||
def test_edit_survey_point():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(Name="Test")
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(),Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file,relating_object=project,products=[site])
|
||||
site = file.createIfcSite(GlobalId=ifcopenshell.guid.new(), Name="MySite")
|
||||
ifcopenshell.api.aggregate.assign_object(file, relating_object=project, products=[site])
|
||||
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
||||
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
||||
file,
|
||||
@@ -36,13 +36,12 @@ def test_edit_survey_point():
|
||||
parent=geometric_representation_context,
|
||||
)
|
||||
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file,file.createIfcCartesianPoint((50.0,10.0)))
|
||||
annotation = ifcopenshell.api.cogo.add_survey_point(file, file.createIfcCartesianPoint((50.0, 10.0)))
|
||||
assert annotation
|
||||
assert annotation.PredefinedType == "SURVEY"
|
||||
assert annotation.Representation.Representations[0].RepresentationIdentifier == "Annotation"
|
||||
assert annotation.Representation.Representations[0].RepresentationType == "Point"
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0,10.0))
|
||||
|
||||
ifcopenshell.api.cogo.edit_survey_point(annotation,20.0,30.0)
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0,30.0))
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((50.0, 10.0))
|
||||
|
||||
ifcopenshell.api.cogo.edit_survey_point(annotation, 20.0, 30.0)
|
||||
assert annotation.Representation.Representations[0].Items[0].Coordinates == pytest.approx((20.0, 30.0))
|
||||
|
||||
@@ -19,57 +19,60 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.stationing as sta
|
||||
|
||||
|
||||
def _test_si_stations():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") # meter
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
|
||||
s = sta.station_as_string(file,0.0)
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") # meter
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
|
||||
s = sta.station_as_string(file, 0.0)
|
||||
assert s == "0+000.000"
|
||||
|
||||
s = sta.station_as_string(file,100.00)
|
||||
s = sta.station_as_string(file, 100.00)
|
||||
assert s == "0+100.000"
|
||||
|
||||
s = sta.station_as_string(file,-100.00)
|
||||
s = sta.station_as_string(file, -100.00)
|
||||
assert s == "-0+100.000"
|
||||
|
||||
s = sta.station_as_string(file,123456.789)
|
||||
s = sta.station_as_string(file, 123456.789)
|
||||
assert s == "123+456.789"
|
||||
|
||||
s = sta.station_as_string(file,-123456.789)
|
||||
s = sta.station_as_string(file, -123456.789)
|
||||
assert s == "-123+456.789"
|
||||
|
||||
|
||||
def _test_si_stations_millimeter():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
ifcopenshell.api.unit.assign_unit(file)
|
||||
|
||||
s = sta.station_as_string(file,100.00)
|
||||
s = sta.station_as_string(file, 100.00)
|
||||
assert s == "0+000.100"
|
||||
|
||||
s = sta.station_as_string(file,1000.00)
|
||||
s = sta.station_as_string(file, 1000.00)
|
||||
assert s == "0+001.000"
|
||||
|
||||
|
||||
def _test_us_stations():
|
||||
file = ifcopenshell.file(schema="IFC4X3_ADD2")
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(),Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file,name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file,units=[length])
|
||||
|
||||
s = sta.station_as_string(file,0.0)
|
||||
project = file.createIfcProject(GlobalId=ifcopenshell.guid.new(), Name="Test")
|
||||
length = ifcopenshell.api.unit.add_conversion_based_unit(file, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(file, units=[length])
|
||||
|
||||
s = sta.station_as_string(file, 0.0)
|
||||
assert s == "0+00.00"
|
||||
|
||||
s = sta.station_as_string(file,100.00)
|
||||
s = sta.station_as_string(file, 100.00)
|
||||
assert s == "1+00.00"
|
||||
|
||||
s = sta.station_as_string(file,-100.00)
|
||||
s = sta.station_as_string(file, -100.00)
|
||||
assert s == "-1+00.00"
|
||||
|
||||
s = sta.station_as_string(file,123456.789)
|
||||
s = sta.station_as_string(file, 123456.789)
|
||||
assert s == "1234+56.79"
|
||||
|
||||
s = sta.station_as_string(file,-123456.789)
|
||||
s = sta.station_as_string(file, -123456.789)
|
||||
assert s == "-1234+56.79"
|
||||
|
||||
|
||||
@@ -79,4 +82,4 @@ def test_station_as_string():
|
||||
_test_us_stations()
|
||||
|
||||
|
||||
test_station_as_string()
|
||||
test_station_as_string()
|
||||
|
||||
Reference in New Issue
Block a user