From ddfb974ae37712bc0a92143f9f8d4e4a402f8070 Mon Sep 17 00:00:00 2001 From: StudioWEngineers Date: Mon, 16 Dec 2024 17:40:24 +0100 Subject: [PATCH] AddPoint with attributes - add Python tests --- tests/python/test_File3dm_ObjectTable.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/python/test_File3dm_ObjectTable.py b/tests/python/test_File3dm_ObjectTable.py index 74ef8f6c..e7da769b 100644 --- a/tests/python/test_File3dm_ObjectTable.py +++ b/tests/python/test_File3dm_ObjectTable.py @@ -3,6 +3,28 @@ #objective: to test that passing a list of points or a Point3dList to the CreateControlPointCurve method returns the same curve class TestFile3dmObjectTable(unittest.TestCase): + def test_addPoint(self) -> None: + """Tests for the `AddPoint` method. + """ + file_3dm = rhino3dm.File3dm() + + # create layers + file_3dm.Layers.AddLayer("layer1", (30, 144, 255, 255)) + file_3dm.Layers.AddLayer("layer2", (255, 215, 0, 255)) + + # points added without attributes are added to the current layer, i.e., the first + # layer added to the model + file_3dm.Objects.AddPoint(rhino3dm.Point3d(0, 0, 0)) + with self.subTest(msg="AddPoint without attributes"): + self.assertEqual(file_3dm.Objects[0].Attributes.LayerIndex, 0) + + # add point with attributes + obj_attr = rhino3dm.ObjectAttributes() + obj_attr.LayerIndex = 1 + file_3dm.Objects.AddPoint(rhino3dm.Point3d(1, 1, 0), obj_attr) + with self.subTest(msg="AddPoint with attributes"): + self.assertEqual(file_3dm.Objects[1].Attributes.LayerIndex, 1) + def test_addPolyline(self): pointArray = []