2025-07-08 10:09:14 -07:00
|
|
|
# IfcOpenShell - IFC toolkit and geometry engine
|
|
|
|
|
# Copyright (C) 2025 Thomas Krijnen <thomas@aecgeeks.com>
|
|
|
|
|
#
|
|
|
|
|
# This file is part of IfcOpenShell.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2026-05-06 11:41:43 +02:00
|
|
|
import pytest
|
|
|
|
|
|
2025-07-08 10:09:14 -07:00
|
|
|
import ifcopenshell.api.alignment
|
2025-07-10 11:30:09 +05:00
|
|
|
import ifcopenshell.api.context
|
|
|
|
|
import ifcopenshell.api.unit
|
2025-07-08 10:09:14 -07:00
|
|
|
|
2025-07-09 13:47:32 +05:00
|
|
|
|
2026-05-06 11:41:43 +02:00
|
|
|
try:
|
|
|
|
|
ifcopenshell.file(schema="IFC4X3")
|
|
|
|
|
IFC4X3_AVAILABLE = True
|
|
|
|
|
except RuntimeError:
|
|
|
|
|
IFC4X3_AVAILABLE = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(not IFC4X3_AVAILABLE, reason="IFC4X3 not available")
|
2025-07-08 10:09:14 -07:00
|
|
|
def test_get_layout_curve():
|
|
|
|
|
file = ifcopenshell.file(schema="IFC4X3")
|
2025-07-09 13:47:32 +05:00
|
|
|
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])
|
2025-07-08 10:09:14 -07:00
|
|
|
geometric_representation_context = ifcopenshell.api.context.add_context(file, context_type="Model")
|
|
|
|
|
axis_model_representation_subcontext = ifcopenshell.api.context.add_context(
|
|
|
|
|
file,
|
|
|
|
|
context_type="Model",
|
|
|
|
|
context_identifier="Axis",
|
|
|
|
|
target_view="MODEL_VIEW",
|
|
|
|
|
parent=geometric_representation_context,
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-09 13:47:32 +05:00
|
|
|
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=False, include_cant=False)
|
2025-07-08 10:09:14 -07:00
|
|
|
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcCompositeCurve")
|
|
|
|
|
|
2025-07-09 13:47:32 +05:00
|
|
|
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=False)
|
2025-07-08 10:09:14 -07:00
|
|
|
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcCompositeCurve")
|
|
|
|
|
layout = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcGradientCurve")
|
|
|
|
|
|
2025-07-09 13:47:32 +05:00
|
|
|
alignment = ifcopenshell.api.alignment.create(file, "TestAlignment", include_vertical=True, include_cant=True)
|
2025-07-08 10:09:14 -07:00
|
|
|
layout = ifcopenshell.api.alignment.get_horizontal_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcCompositeCurve")
|
|
|
|
|
layout = ifcopenshell.api.alignment.get_vertical_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcGradientCurve")
|
|
|
|
|
layout = ifcopenshell.api.alignment.get_cant_layout(alignment)
|
|
|
|
|
curve = ifcopenshell.api.alignment.get_layout_curve(layout)
|
|
|
|
|
assert curve.is_a("IfcSegmentedReferenceCurve")
|