diff --git a/doc/changelog.d/1258.test.md b/doc/changelog.d/1258.test.md new file mode 100644 index 0000000000..7cde69eb55 --- /dev/null +++ b/doc/changelog.d/1258.test.md @@ -0,0 +1 @@ +verifying issue with empty intersect and temporal body creation \ No newline at end of file diff --git a/tests/integration/test_design_import.py b/tests/integration/test_design_import.py index 6c0233d2f4..a2a5847932 100644 --- a/tests/integration/test_design_import.py +++ b/tests/integration/test_design_import.py @@ -251,8 +251,8 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory): # IGES # # TODO: Something has gone wrong with IGES - # https://github.com/ansys/pyansys-geometry/issues/801 - + # https://github.com/ansys/pyansys-geometry/issues/1146 + # # file = tmp_path_factory.mktemp("test_design_import") / "two_cars.igs" # design.download(file, DesignFileFormat.IGES) # design2 = modeler.open_file(file) diff --git a/tests/integration/test_issues.py b/tests/integration/test_issues.py index f1a3b4ce3e..6865e4e287 100644 --- a/tests/integration/test_issues.py +++ b/tests/integration/test_issues.py @@ -139,6 +139,51 @@ def test_issue_1304_arc_sketch_creation(): DEFAULT_UNITS.LENGTH = UNITS.meter +def test_issue_1192_temp_body_on_empty_intersect(modeler: Modeler): + """Test demonstrating the issue when intersecting two bodies that do not intersect + and the empty temporal body that gets created.""" + # When attempting to intersect two bodies that do not intersect, no body should be + # created. However, in the past, a temporary body was created and added to the + # component. This test checks if this issue has been resolved. + design = modeler.create_design("temp-body-intersect-issue") + + # Create two bodies that do not intersect + plane = Plane( + Point3D([1 / 2, 1 / 2, 0.0]), + UNITVECTOR3D_X, + UNITVECTOR3D_Y, + ) + matrix_plane = Sketch(plane) + matrix_plane.box(Point2D([0.0, 0.0]), width=1, height=1) + matrix = design.extrude_sketch("Matrix", matrix_plane, 1) + + p = Point3D([1.0, 1.0, 1.5]) + plane = Plane(p, UNITVECTOR3D_X, UNITVECTOR3D_Y) + sketch_fibres = Sketch(plane) + sketch_fibres.circle(Point2D([0.0, 0.0]), radius=0.5) + fibre = design.extrude_sketch("fibre", sketch_fibres, 1) + + # Attempt intersection - which fails and thus deletes copy + matrix_copy = matrix.copy(design) + try: + fibre.intersect(matrix_copy) + except Exception: + design.delete_body(matrix_copy) + + # No intersection took place... so no body should be created + # Let's read the design and check that only the two bodies are present + read_design = modeler.read_existing_design() + + # Verify the design + assert len(read_design.bodies) == 2 + assert len(read_design.bodies) == 2 + assert len(read_design.bodies[0].faces) == 6 + assert len(read_design.bodies[1].faces) == 3 + assert read_design.bodies[0].name == "Matrix" + assert read_design.bodies[1].name == "fibre" + assert len(read_design.components) == 0 + + def test_issue_1309_revolve_operation_with_coincident_origins(modeler: Modeler): """Test that revolving a sketch with coincident origins (sketch and rotation origin) does not crash the program.