This commit is contained in:
Andrej730
2025-07-09 13:47:32 +05:00
parent 40f92d15c3
commit 5a4ad69bf7
30 changed files with 362 additions and 301 deletions
@@ -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))