@@ -1991,7 +1991,6 @@ def test_get_active_design(modeler: Modeler):
19911991
19921992def test_get_collision (modeler : Modeler ):
19931993 """Test the collision state between two bodies."""
1994- skip_if_linux (modeler , test_get_collision .__name__ , "get_collision" ) # Skip test on Linux
19951994 design = modeler .open_file (FILES_DIR / "MixingTank.scdocx" )
19961995 body1 = design .bodies [0 ]
19971996 body2 = design .bodies [1 ]
@@ -2784,3 +2783,79 @@ def test_cached_bodies(modeler: Modeler):
27842783 for body1 , body3 in zip (my_bodies , my_bodies_3 ):
27852784 assert body1 is not body3
27862785 assert id (body1 ) != id (body3 )
2786+
2787+
2788+ def test_extrude_sketch_with_cut_request (modeler : Modeler ):
2789+ """Test the cut argument when performing a sketch extrusion.
2790+
2791+ This method mimics a cut operation.
2792+
2793+ Behind the scenes, a subtraction operation is performed on the bodies. After extruding the
2794+ sketch, the resulting body should be a cut body.
2795+ """
2796+ # Define a sketch
2797+ origin = Point3D ([0 , 0 , 10 ])
2798+ plane = Plane (origin , direction_x = [1 , 0 , 0 ], direction_y = [0 , 1 , 0 ])
2799+
2800+ # Create a sketch
2801+ sketch_box = Sketch (plane )
2802+ sketch_box .box (Point2D ([20 , 20 ]), 30 * UNITS .m , 30 * UNITS .m )
2803+
2804+ sketch_cylinder = Sketch (plane )
2805+ sketch_cylinder .circle (Point2D ([20 , 20 ]), 5 * UNITS .m )
2806+
2807+ # Create a design
2808+ design = modeler .create_design ("ExtrudeSketchWithCut" )
2809+
2810+ box_body = design .extrude_sketch (
2811+ name = "BoxBody" , sketch = sketch_box , distance = Distance (30 , unit = UNITS .m )
2812+ )
2813+ volume_box = box_body .volume
2814+
2815+ design .extrude_sketch (
2816+ name = "CylinderBody" , sketch = sketch_cylinder , distance = Distance (60 , unit = UNITS .m ), cut = True
2817+ )
2818+
2819+ # Verify there is only one body
2820+ assert len (design .bodies ) == 1
2821+
2822+ # Verify the volume of the resulting body is less than the volume of the box
2823+ assert design .bodies [0 ].volume < volume_box
2824+
2825+
2826+ def test_extrude_sketch_with_cut_request_no_collision (modeler : Modeler ):
2827+ """Test the cut argument when performing a sketch extrusion (with no collision).
2828+
2829+ This method mimics an unsuccessful cut operation.
2830+
2831+ The sketch extrusion should not result in a cut body since there is no collision between the
2832+ original body and the extruded body.
2833+ """
2834+ # Define a sketch
2835+ origin = Point3D ([0 , 0 , 10 ])
2836+ plane = Plane (origin , direction_x = [1 , 0 , 0 ], direction_y = [0 , 1 , 0 ])
2837+
2838+ # Create a sketch
2839+ sketch_box = Sketch (plane )
2840+ sketch_box .box (Point2D ([20 , 20 ]), 30 * UNITS .m , 30 * UNITS .m )
2841+
2842+ sketch_cylinder = Sketch (plane )
2843+ sketch_cylinder .circle (Point2D ([100 , 100 ]), 5 * UNITS .m )
2844+
2845+ # Create a design
2846+ design = modeler .create_design ("ExtrudeSketchWithCutNoCollision" )
2847+
2848+ box_body = design .extrude_sketch (
2849+ name = "BoxBody" , sketch = sketch_box , distance = Distance (30 , unit = UNITS .m )
2850+ )
2851+ volume_box = box_body .volume
2852+
2853+ design .extrude_sketch (
2854+ name = "CylinderBody" , sketch = sketch_cylinder , distance = Distance (60 , unit = UNITS .m ), cut = True
2855+ )
2856+
2857+ # Verify there is only one body... the cut operation should delete it
2858+ assert len (design .bodies ) == 1
2859+
2860+ # Verify the volume of the resulting body is exactly the same
2861+ assert design .bodies [0 ].volume == volume_box
0 commit comments