File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 11import cadquery as cq
22
33
4+ def generate_nested_boxes ():
5+ """
6+ Generates a simple assembly of two cubes where one is nested inside the other.
7+ """
8+
9+ # Cube that is nested completely inside the other one
10+ inside_cube = cq .Workplane ().box (5 , 5 , 5 )
11+
12+ # Use the inside cube to make a void inside the outside cube
13+ outside_cube = cq .Workplane ().box (10 , 10 , 10 )
14+ outside_cube = outside_cube .cut (inside_cube )
15+
16+ # Create the assembly
17+ assy = cq .Assembly ()
18+ assy .add (
19+ outside_cube ,
20+ name = "outside_cube" ,
21+ loc = cq .Location (cq .Vector (0 , 0 , 0 )),
22+ color = cq .Color ("blue" ),
23+ )
24+ assy .add (
25+ inside_cube ,
26+ name = "inside_cube" ,
27+ loc = cq .Location (cq .Vector (0 , 0 , 0 )),
28+ color = cq .Color ("red" ),
29+ )
30+
31+ return assy
32+
33+
434def generate_simple_nested_boxes ():
535 """
636 Generates the simplest assembly case where two boxes are nested inside each other.
Original file line number Diff line number Diff line change 11import assembly_mesh_plugin .plugin
22from tests .sample_assemblies import (
3+ generate_nested_boxes ,
34 generate_simple_nested_boxes ,
45 generate_test_cross_section ,
56 generate_assembly ,
67)
78
89
10+ def test_nested_cubes ():
11+ """
12+ Tests to make sure that the nested cubes do not cause the correct number of surfaces
13+ in the mesh.
14+ """
15+
16+ # Create the basic assembly
17+ assy = generate_nested_boxes ()
18+
19+ # Convert the assembly to a GMSH mesh
20+ gmsh = assy .getTaggedGmsh ()
21+
22+ # Make sure we have the correct number of surfaces
23+ surfaces = gmsh .model .getEntities (2 )
24+ assert len (surfaces ) == 18
25+
26+
927def test_basic_assembly ():
1028 """
1129 Tests to make sure that the most basic assembly works correctly with tagging.
You can’t perform that action at this time.
0 commit comments