@@ -139,6 +139,51 @@ def test_issue_1304_arc_sketch_creation():
139139 DEFAULT_UNITS .LENGTH = UNITS .meter
140140
141141
142+ def test_issue_1192_temp_body_on_empty_intersect (modeler : Modeler ):
143+ """Test demonstrating the issue when intersecting two bodies that do not intersect
144+ and the empty temporal body that gets created."""
145+ # When attempting to intersect two bodies that do not intersect, no body should be
146+ # created. However, in the past, a temporary body was created and added to the
147+ # component. This test checks if this issue has been resolved.
148+ design = modeler .create_design ("temp-body-intersect-issue" )
149+
150+ # Create two bodies that do not intersect
151+ plane = Plane (
152+ Point3D ([1 / 2 , 1 / 2 , 0.0 ]),
153+ UNITVECTOR3D_X ,
154+ UNITVECTOR3D_Y ,
155+ )
156+ matrix_plane = Sketch (plane )
157+ matrix_plane .box (Point2D ([0.0 , 0.0 ]), width = 1 , height = 1 )
158+ matrix = design .extrude_sketch ("Matrix" , matrix_plane , 1 )
159+
160+ p = Point3D ([1.0 , 1.0 , 1.5 ])
161+ plane = Plane (p , UNITVECTOR3D_X , UNITVECTOR3D_Y )
162+ sketch_fibres = Sketch (plane )
163+ sketch_fibres .circle (Point2D ([0.0 , 0.0 ]), radius = 0.5 )
164+ fibre = design .extrude_sketch ("fibre" , sketch_fibres , 1 )
165+
166+ # Attempt intersection - which fails and thus deletes copy
167+ matrix_copy = matrix .copy (design )
168+ try :
169+ fibre .intersect (matrix_copy )
170+ except Exception :
171+ design .delete_body (matrix_copy )
172+
173+ # No intersection took place... so no body should be created
174+ # Let's read the design and check that only the two bodies are present
175+ read_design = modeler .read_existing_design ()
176+
177+ # Verify the design
178+ assert len (read_design .bodies ) == 2
179+ assert len (read_design .bodies ) == 2
180+ assert len (read_design .bodies [0 ].faces ) == 6
181+ assert len (read_design .bodies [1 ].faces ) == 3
182+ assert read_design .bodies [0 ].name == "Matrix"
183+ assert read_design .bodies [1 ].name == "fibre"
184+ assert len (read_design .components ) == 0
185+
186+
142187def test_issue_1309_revolve_operation_with_coincident_origins (modeler : Modeler ):
143188 """Test that revolving a sketch with coincident origins (sketch and rotation origin)
144189 does not crash the program.
0 commit comments