File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1
1
import cadquery as cq
2
2
3
3
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
+
4
34
def generate_simple_nested_boxes ():
5
35
"""
6
36
Generates the simplest assembly case where two boxes are nested inside each other.
Original file line number Diff line number Diff line change 1
1
import assembly_mesh_plugin .plugin
2
2
from tests .sample_assemblies import (
3
+ generate_nested_boxes ,
3
4
generate_simple_nested_boxes ,
4
5
generate_test_cross_section ,
5
6
generate_assembly ,
6
7
)
7
8
8
9
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
+
9
27
def test_basic_assembly ():
10
28
"""
11
29
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