diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 582ed4b0ea..ed777bdd57 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -613,28 +613,30 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) curve = builder.rectangle(size=Vector((0.5, 0.5)) / unit_scale) - - if not (props.ifc_product == "IfcFeatureElement" and - props.ifc_class == "IfcOpeningElement" and - props.featured_obj): + + if not ( + props.ifc_product == "IfcFeatureElement" + and props.ifc_class == "IfcOpeningElement" + and props.featured_obj + ): item = builder.extrude(curve, magnitude=0.5 / unit_scale) else: featured_element = tool.Ifc.get_entity(props.featured_obj) usage = ifcopenshell.util.element.get_material(featured_element) if featured_element else None - + if usage and usage.is_a("IfcMaterialLayerSetUsage"): wall_matrix = props.featured_obj.matrix_world - + profile = builder.profile(curve) local_x = wall_matrix.to_3x3() @ Vector((1, 0, 0)) - local_y = wall_matrix.to_3x3() @ Vector((0, 1, 0)) - local_z = wall_matrix.to_3x3() @ Vector((0, 0, 1)) - direction_sense = getattr(usage, 'DirectionSense', 'POSITIVE') + local_y = wall_matrix.to_3x3() @ Vector((0, 1, 0)) + local_z = wall_matrix.to_3x3() @ Vector((0, 0, 1)) + direction_sense = getattr(usage, "DirectionSense", "POSITIVE") if usage.LayerSetDirection == "AXIS2": - z_axis = tuple(local_y) if direction_sense == 'POSITIVE' else tuple(-local_y) + z_axis = tuple(local_y) if direction_sense == "POSITIVE" else tuple(-local_y) elif usage.LayerSetDirection == "AXIS3": - z_axis = tuple(local_z) if direction_sense == 'POSITIVE' else tuple(-local_z) + z_axis = tuple(local_z) if direction_sense == "POSITIVE" else tuple(-local_z) item = builder.extrude( profile, diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_get_cant_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_get_cant_segment.py index fe88d33c61..ccf466828b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_get_cant_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_get_cant_segment.py @@ -34,10 +34,12 @@ def _get_cant_segment(horizontal_segment: entity_instance) -> entity_instance: expected_type = "IfcAlignmentSegment" if not horizontal_segment.is_a(expected_type): raise TypeError(f"Expected {expected_type} but got {horizontal_segment.is_a()}") - + if not horizontal_segment.DesignParameters.is_a("IfcAlignmentHorizontalSegment"): - raise TypeError(f"Expect DesignParameter to be IfcAlignmentHorizontal but got {horizontal_segment.DesignParameters.is_a()}") - + raise TypeError( + f"Expect DesignParameter to be IfcAlignmentHorizontal but got {horizontal_segment.DesignParameters.is_a()}" + ) + # get the index of horizontal_segment in the horizontal_layout horizontal_layout = horizontal_segment.Nests[0].RelatingObject index = 0 @@ -71,7 +73,5 @@ def _get_cant_segment(horizontal_segment: entity_instance) -> entity_instance: break if cant_segment: break - return cant_segment - diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_cant_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_cant_segment.py index d24a6d9135..c86edc110e 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_cant_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_cant_segment.py @@ -392,10 +392,10 @@ def _map_viennese_bend( a1 = 0.0 # linear term a2 = 0.0 * f # quadratic term a3 = 0.0 * f # cubic term - a4 = 35. * f # quartic term - a5 = -84.*f # quintic term - a6 = 70.*f # sextic term - a7 = -20.*f # septic term + a4 = 35.0 * f # quartic term + a5 = -84.0 * f # quintic term + a6 = 70.0 * f # sextic term + a7 = -20.0 * f # septic term transition = "DISCONTINUOUS" diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py index 64b2a64b0d..3e7cd26f3c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_map_alignment_horizontal_segment.py @@ -437,7 +437,9 @@ def _map_viennese_bend(file: ifcopenshell.file, segment: entity_instance) -> Seq start_direction = design_parameters.StartDirection start_radius = design_parameters.StartRadiusOfCurvature length = design_parameters.SegmentLength - gravity_centerline_height = design_parameters.GravityCenterLineHeight if design_parameters.GravityCenterLineHeight != None else 0.0 + gravity_centerline_height = ( + design_parameters.GravityCenterLineHeight if design_parameters.GravityCenterLineHeight != None else 0.0 + ) angle_unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file, "PLANEANGLEUNIT") start_direction *= angle_unit_scale @@ -449,40 +451,42 @@ def _map_viennese_bend(file: ifcopenshell.file, segment: entity_instance) -> Seq start_cant_left = cant_segment.DesignParameters.StartCantLeft end_cant_left = cant_segment.DesignParameters.EndCantLeft if cant_segment.DesignParameters.EndCantLeft else 0.0 start_cant_right = cant_segment.DesignParameters.StartCantRight - end_cant_right = cant_segment.DesignParameters.EndCantRight if cant_segment.DesignParameters.EndCantRight else 0.0 + end_cant_right = ( + cant_segment.DesignParameters.EndCantRight if cant_segment.DesignParameters.EndCantRight else 0.0 + ) cant_layout = cant_segment.Nests[0].RelatingObject rail_head_distance = cant_layout.RailHeadDistance else: - start_cant_left = 0. - end_cant_left = 0. - start_cant_right = 0. - end_cant_right = 0. - rail_head_distance = 1. + start_cant_left = 0.0 + end_cant_left = 0.0 + start_cant_right = 0.0 + end_cant_right = 0.0 + rail_head_distance = 1.0 - cant_angle_start = (start_cant_right - start_cant_left)/rail_head_distance if rail_head_distance else 0. - cant_angle_end = (end_cant_right - end_cant_left)/rail_head_distance if rail_head_distance else 0. + cant_angle_start = (start_cant_right - start_cant_left) / rail_head_distance if rail_head_distance else 0.0 + cant_angle_end = (end_cant_right - end_cant_left) / rail_head_distance if rail_head_distance else 0.0 - cant_factor = -420.*(gravity_centerline_height/length)*(cant_angle_end - cant_angle_start) + cant_factor = -420.0 * (gravity_centerline_height / length) * (cant_angle_end - cant_angle_start) f = _get_curve_factor(design_parameters) - a0 = length / start_radius if start_radius != 0.0 else 0.0 # constant term - a1 = 0. # linear term - a2 = 1.*cant_factor # quadratic term - a3 = -4.*cant_factor # cubic term - a4 = 5.*cant_factor + 35.*f # quartic term - a5 = -2.*cant_factor - 84.*f # quintic term - a6 = 70.*f # sextic term - a7 = -20.0*f # septic term + a0 = length / start_radius if start_radius != 0.0 else 0.0 # constant term + a1 = 0.0 # linear term + a2 = 1.0 * cant_factor # quadratic term + a3 = -4.0 * cant_factor # cubic term + a4 = 5.0 * cant_factor + 35.0 * f # quartic term + a5 = -2.0 * cant_factor - 84.0 * f # quintic term + a6 = 70.0 * f # sextic term + a7 = -20.0 * f # septic term - A0 = length*math.pow(math.fabs(a0),-1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 - A1 = length*math.pow(math.fabs(a1),-1.0 / 2.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 - A2 = length*math.pow(math.fabs(a2),-1.0 / 3.0) * (a2 / math.fabs(a2)) if a2 != 0.0 else 0.0 - A3 = length*math.pow(math.fabs(a3),-1.0 / 4.0) * (a3 / math.fabs(a3)) if a3 != 0.0 else 0.0 - A4 = length*math.pow(math.fabs(a4),-1.0 / 5.0) * (a4 / math.fabs(a4)) if a4 != 0.0 else 0.0 - A5 = length*math.pow(math.fabs(a5),-1.0 / 6.0) * (a5 / math.fabs(a5)) if a5 != 0.0 else 0.0 - A6 = length*math.pow(math.fabs(a6),-1.0 / 7.0) * (a6 / math.fabs(a6)) if a6 != 0.0 else 0.0 - A7 = length*math.pow(math.fabs(a7),-1.0 / 8.0) * (a7 / math.fabs(a7)) if a7 != 0.0 else 0.0 + A0 = length * math.pow(math.fabs(a0), -1.0 / 1.0) * (a0 / math.fabs(a0)) if a0 != 0.0 else 0.0 + A1 = length * math.pow(math.fabs(a1), -1.0 / 2.0) * (a1 / math.fabs(a1)) if a1 != 0.0 else 0.0 + A2 = length * math.pow(math.fabs(a2), -1.0 / 3.0) * (a2 / math.fabs(a2)) if a2 != 0.0 else 0.0 + A3 = length * math.pow(math.fabs(a3), -1.0 / 4.0) * (a3 / math.fabs(a3)) if a3 != 0.0 else 0.0 + A4 = length * math.pow(math.fabs(a4), -1.0 / 5.0) * (a4 / math.fabs(a4)) if a4 != 0.0 else 0.0 + A5 = length * math.pow(math.fabs(a5), -1.0 / 6.0) * (a5 / math.fabs(a5)) if a5 != 0.0 else 0.0 + A6 = length * math.pow(math.fabs(a6), -1.0 / 7.0) * (a6 / math.fabs(a6)) if a6 != 0.0 else 0.0 + A7 = length * math.pow(math.fabs(a7), -1.0 / 8.0) * (a7 / math.fabs(a7)) if a7 != 0.0 else 0.0 parent_curve = file.createIfcSeventhOrderPolynomialSpiral( Position=file.createIfcAxis2Placement2D( diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py index 46e0a871e7..021314547c 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_cant_segment.py @@ -1605,277 +1605,294 @@ def _SineCurve_100_0__inf__300_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(3535.53390593274) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + def _VienneseBend_100_0_300_1000_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.0, - EndCantLeft=0.0, - StartCantRight=0.1, - EndCantRight=0.03, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.1, + EndCantRight=0.03, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(185.93568367635672) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-169.87095595653895) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(180.0012184608678) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-241.1974890085123) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(185.93568367635672) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-169.87095595653895) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(180.0012184608678) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-241.1974890085123) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) def _VienneseBend_100_0__300__1000_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.1, - EndCantLeft=0.03, - StartCantRight=0.0, - EndCantRight=0.0, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.1, + EndCantLeft=0.03, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(185.93568367635672) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-169.87095595653895) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(180.0012184608678) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-241.1974890085123) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(185.93568367635672) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-169.87095595653895) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(180.0012184608678) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-241.1974890085123) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) def _VienneseBend_100_0_300_inf_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.0, - EndCantLeft=0.0, - StartCantRight=0.1, - EndCantRight=0.0, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.1, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(177.82794100389228) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-161.4322423756691) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(169.6127328157867) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-224.5910214113641) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(177.82794100389228) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-161.4322423756691) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(169.6127328157867) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-224.5910214113641) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) def _VienneseBend_100_0__300__inf_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.1, - EndCantLeft=0.0, - StartCantRight=0.0, - EndCantRight=0.0, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.1, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(177.82794100389228) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-161.4322423756691) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(169.6127328157867) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-224.5910214113641) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.05, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(177.82794100389228) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-161.4322423756691) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(169.6127328157867) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(-224.5910214113641) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(200000.0) def _VienneseBend_100_0_1000_300_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.0, - EndCantLeft=0.0, - StartCantRight=0.03, - EndCantRight=0.1, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.03, + EndCantRight=0.1, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.015, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-185.93568367635672) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(169.87095595653895) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-180.0012184608678) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(241.1974890085123) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(666666.666666667) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.015, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-185.93568367635672) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(169.87095595653895) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-180.0012184608678) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(241.1974890085123) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(666666.666666667) def _VienneseBend_100_0__1000__300_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.03, - EndCantLeft=0.1, - StartCantRight=0.0, - EndCantRight=0.0, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.03, + EndCantLeft=0.1, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.015, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-185.93568367635672) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(169.87095595653895) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-180.0012184608678) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(241.1974890085123) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(666666.666666667) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.015, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-185.93568367635672) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(169.87095595653895) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-180.0012184608678) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(241.1974890085123) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(666666.666666667) def _VienneseBend_100_0_inf_300_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.0, - EndCantLeft=0.0, - StartCantRight=0.0, - EndCantRight=0.1, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.1, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-177.82794100389228) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(161.4322423756691) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-169.6127328157867) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(224.5910214113641) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-177.82794100389228) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(161.4322423756691) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-169.6127328157867) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(224.5910214113641) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) def _VienneseBend_100_0__inf__300_1_Meter(file): - design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0.0, - HorizontalLength=100.0, - StartCantLeft=0.0, - EndCantLeft=0.1, - StartCantRight=0.0, - EndCantRight=0.0, - PredefinedType="VIENNESEBEND") + design_parameters = file.createIfcAlignmentCantSegment( + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.1, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", + ) - alignment_segment = file.createIfcAlignmentSegment( - GlobalId=ifcopenshell.guid.new(), - DesignParameters=design_parameters) + alignment_segment = file.createIfcAlignmentSegment( + GlobalId=ifcopenshell.guid.new(), DesignParameters=design_parameters + ) + + mapped_segments = _map_alignment_cant_segment(file, alignment_segment, 1.5) + mapped_segment = mapped_segments[0] + assert len(mapped_segments) == 2 + assert "DISCONTINUOUS" == mapped_segment.Transition + assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) + assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) + assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) + assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) + assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") + assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) + assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-177.82794100389228) + assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(161.4322423756691) + assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-169.6127328157867) + assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(224.5910214113641) + assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) + assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) - mapped_segments = _map_alignment_cant_segment(file,alignment_segment, 1.5) - mapped_segment = mapped_segments[0] - assert len(mapped_segments) == 2 - assert "DISCONTINUOUS" == mapped_segment.Transition - assert mapped_segment.Placement.Location.Coordinates == pytest.approx((0.0, 0.0, 0.0)) - assert mapped_segment.Placement.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0, 0.0)) - assert mapped_segment.SegmentStart.wrappedValue == pytest.approx(0.0) - assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) - assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") - assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) - assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-177.82794100389228) - assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(161.4322423756691) - assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-169.6127328157867) - assert mapped_segment.ParentCurve.QuarticTerm == pytest.approx(224.5910214113641) - assert mapped_segment.ParentCurve.CubicTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.QuadraticTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) - assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) def test_map_alignment_cant_segment(): file = ifcopenshell.file(schema="IFC4X3") diff --git a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py index e3ef4cac20..8eee09ae0d 100644 --- a/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py +++ b/src/ifcopenshell-python/test/api/alignment/test_map_alignment_horizontal_segment.py @@ -2031,53 +2031,54 @@ def _SineCurve_100_0__inf__300_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(-173.205080756888) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + def _VienneseBend_100_0_300_1000_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) # for viennese bends, the horizontal layout depends on the cant layout # for this reason, define the cant segment before the horizontal segment cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., - StartCantLeft=0., - EndCantLeft=0., + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, StartCantRight=0.1, EndCantRight=0.03, - PredefinedType="VIENNESEBEND" - + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=300.0, - EndRadiusOfCurvature=1000.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=300.0, + EndRadiusOfCurvature=1000.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2087,7 +2088,7 @@ def _VienneseBend_100_0_300_1000_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(82.48484305114) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-67.097076273516) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(61.2742234216927) @@ -2097,51 +2098,52 @@ def _VienneseBend_100_0_300_1000_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(300.0) + def _VienneseBend_100_0__300__1000_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., + StartDistAlong=0.0, + HorizontalLength=100.0, StartCantLeft=0.1, EndCantLeft=0.03, - StartCantRight=0., - EndCantRight=0., - PredefinedType="VIENNESEBEND" - + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=-300.0, - EndRadiusOfCurvature=-1000.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=-300.0, + EndRadiusOfCurvature=-1000.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2151,7 +2153,7 @@ def _VienneseBend_100_0__300__1000_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-82.48484305114) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(67.097076273516) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-61.2742234216927) @@ -2161,51 +2163,52 @@ def _VienneseBend_100_0__300__1000_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-300.0) + def _VienneseBend_100_0_300_inf_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., - StartCantLeft=0., - EndCantLeft=0., + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, StartCantRight=0.1, - EndCantRight=0., - PredefinedType="VIENNESEBEND" - + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=300.0, - EndRadiusOfCurvature=0.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=300.0, + EndRadiusOfCurvature=0.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2215,7 +2218,7 @@ def _VienneseBend_100_0_300_inf_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(78.8880838459446) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-63.7638813456506) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(57.7378785242934) @@ -2225,51 +2228,52 @@ def _VienneseBend_100_0_300_inf_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(300.0) + def _VienneseBend_100_0__300__inf_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., + StartDistAlong=0.0, + HorizontalLength=100.0, StartCantLeft=0.1, - EndCantLeft=0., - StartCantRight=0., - EndCantRight=0., - PredefinedType="VIENNESEBEND" - + EndCantLeft=0.0, + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=-300.0, - EndRadiusOfCurvature=0.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=-300.0, + EndRadiusOfCurvature=0.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2279,7 +2283,7 @@ def _VienneseBend_100_0__300__inf_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-78.8880838459446) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(63.7638813456506) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-57.7378785242934) @@ -2289,50 +2293,52 @@ def _VienneseBend_100_0__300__inf_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-300.0) + def _VienneseBend_100_0_1000_300_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., - StartCantLeft=0., - EndCantLeft=0., + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, StartCantRight=0.03, EndCantRight=0.1, - PredefinedType="VIENNESEBEND" + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=1000.0, - EndRadiusOfCurvature=300.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=1000.0, + EndRadiusOfCurvature=300.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2342,7 +2348,7 @@ def _VienneseBend_100_0_1000_300_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-82.48484305114) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(67.097076273516) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-61.2742234216927) @@ -2352,50 +2358,52 @@ def _VienneseBend_100_0_1000_300_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(1000.0) + def _VienneseBend_100_0__1000__300_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., + StartDistAlong=0.0, + HorizontalLength=100.0, StartCantLeft=0.03, EndCantLeft=0.1, - StartCantRight=0., - EndCantRight=0., - PredefinedType="VIENNESEBEND" + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=-1000.0, - EndRadiusOfCurvature=-300.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=-1000.0, + EndRadiusOfCurvature=-300.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2405,7 +2413,7 @@ def _VienneseBend_100_0__1000__300_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(82.48484305114) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-67.097076273516) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(61.2742234216927) @@ -2415,50 +2423,52 @@ def _VienneseBend_100_0__1000__300_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(-1000.0) + def _VienneseBend_100_0_inf_300_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., - StartCantLeft=0., - EndCantLeft=0., - StartCantRight=0., + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, + EndCantLeft=0.0, + StartCantRight=0.0, EndCantRight=0.1, - PredefinedType="VIENNESEBEND" + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=0.0, - EndRadiusOfCurvature=300.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=0.0, + EndRadiusOfCurvature=300.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2468,7 +2478,7 @@ def _VienneseBend_100_0_inf_300_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(-78.8880838459446) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(63.7638813456506) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(-57.7378785242934) @@ -2478,50 +2488,52 @@ def _VienneseBend_100_0_inf_300_1_Meter(file): assert mapped_segment.ParentCurve.LinearTerm == pytest.approx(None) assert mapped_segment.ParentCurve.ConstantTerm == pytest.approx(None) + def _VienneseBend_100_0__inf__300_1_Meter(file): project = file.createIfcProject(GlobalId=ifcopenshell.guid.new()) - length = ifcopenshell.api.unit.add_si_unit(file,unit_type="LENGTHUNIT") - ifcopenshell.api.unit.assign_unit(file,units=[length]) + length = ifcopenshell.api.unit.add_si_unit(file, unit_type="LENGTHUNIT") + ifcopenshell.api.unit.assign_unit(file, units=[length]) - alignment = ifcopenshell.api.alignment.create(file,"",include_vertical=True,include_cant=True) + alignment = ifcopenshell.api.alignment.create(file, "", include_vertical=True, include_cant=True) cant_layout = ifcopenshell.api.alignment.get_cant_layout(alignment) - cant_layout.RailHeadDistance=1.5 + cant_layout.RailHeadDistance = 1.5 design_parameters = file.createIfcAlignmentCantSegment( - StartDistAlong=0., - HorizontalLength=100., - StartCantLeft=0., + StartDistAlong=0.0, + HorizontalLength=100.0, + StartCantLeft=0.0, EndCantLeft=0.1, - StartCantRight=0., - EndCantRight=0., - PredefinedType="VIENNESEBEND" + StartCantRight=0.0, + EndCantRight=0.0, + PredefinedType="VIENNESEBEND", ) - ifcopenshell.api.alignment.create_layout_segment(file,cant_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, cant_layout, design_parameters) horizontal_layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment) design_parameters = file.createIfcAlignmentHorizontalSegment( - StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), - StartDirection=0.0, - StartRadiusOfCurvature=0.0, - EndRadiusOfCurvature=-300.0, - SegmentLength=100.0, - GravityCenterLineHeight=1.8, - PredefinedType="VIENNESEBEND") - ifcopenshell.api.alignment.create_layout_segment(file,horizontal_layout,design_parameters) + StartPoint=file.createIfcCartesianPoint((0.0, 0.0)), + StartDirection=0.0, + StartRadiusOfCurvature=0.0, + EndRadiusOfCurvature=-300.0, + SegmentLength=100.0, + GravityCenterLineHeight=1.8, + PredefinedType="VIENNESEBEND", + ) + ifcopenshell.api.alignment.create_layout_segment(file, horizontal_layout, design_parameters) vertical_layout = ifcopenshell.api.alignment.get_vertical_layout(alignment) design_parameters = file.createIfcAlignmentVerticalSegment( - StartDistAlong=0., - HorizontalLength=100., - StartHeight=0., - StartGradient=0., - EndGradient=0., - PredefinedType = "CONSTANTGRADIENT" + StartDistAlong=0.0, + HorizontalLength=100.0, + StartHeight=0.0, + StartGradient=0.0, + EndGradient=0.0, + PredefinedType="CONSTANTGRADIENT", ) - ifcopenshell.api.alignment.create_layout_segment(file,vertical_layout,design_parameters) + ifcopenshell.api.alignment.create_layout_segment(file, vertical_layout, design_parameters) alignment_segment = horizontal_layout.IsNestedBy[0].RelatedObjects[0] - mapped_segments = _map_alignment_horizontal_segment(file,alignment_segment) + mapped_segments = _map_alignment_horizontal_segment(file, alignment_segment) mapped_segment = mapped_segments[0] assert len(mapped_segments) == 2 assert "DISCONTINUOUS" == mapped_segment.Transition @@ -2531,7 +2543,7 @@ def _VienneseBend_100_0__inf__300_1_Meter(file): assert mapped_segment.SegmentLength.wrappedValue == pytest.approx(100.0) assert mapped_segment.ParentCurve.is_a("IfcSeventhOrderPolynomialSpiral") assert mapped_segment.ParentCurve.Position.Location.Coordinates == pytest.approx((0.0, 0.0)) - assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0,0.0)) + assert mapped_segment.ParentCurve.Position.RefDirection.DirectionRatios == pytest.approx((1.0, 0.0)) assert mapped_segment.ParentCurve.SepticTerm == pytest.approx(78.8880838459446) assert mapped_segment.ParentCurve.SexticTerm == pytest.approx(-63.7638813456506) assert mapped_segment.ParentCurve.QuinticTerm == pytest.approx(57.7378785242934)