MCPcopy
hub / github.com/CadQuery/cadquery / test_nested_fused_assembly

Function test_nested_fused_assembly

tests/test_exporters.py:134–160  ·  view source on GitHub ↗

Tests a nested assembly being exported as a single, fused solid. The resulting STEP is imported again to test it.

(tmpdir)

Source from the content-addressed store, hash-verified

132
133
134def test_nested_fused_assembly(tmpdir):
135 """
136 Tests a nested assembly being exported as a single, fused solid.
137 The resulting STEP is imported again to test it.
138 """
139 # Create the nested assembly
140 assy = Assembly()
141 body = Workplane().box(10, 10, 10)
142 assy.add(body, color=Color(1, 0, 0), name="body")
143 pins = Assembly()
144 pin1 = Workplane().center(8, 8).cylinder(radius=2, height=20)
145 pin2 = Workplane().center(-8, -8).cylinder(radius=2, height=20)
146 pins.add(pin1, color=Color(0, 1, 0), name="pin1")
147 pins.add(pin2, color=Color(0, 0, 1), name="pin2")
148 assy.add(pins, name="pins")
149
150 # Export the assembly
151 step_path = os.path.join(tmpdir, "nested_fused_assembly.step")
152 assy.save(
153 path=str(step_path),
154 exportType=exporters.ExportTypes.STEP,
155 mode=exporters.assembly.ExportModes.FUSED,
156 )
157
158 # Import the assembly and make sure it acts as expected
159 model = importers.importStep(step_path)
160 assert model.solids().size() == 3
161
162
163def test_fused_assembly_with_one_part(tmpdir):

Callers

nothing calls this directly

Calls 11

addMethod · 0.95
saveMethod · 0.95
AssemblyClass · 0.90
WorkplaneClass · 0.90
ColorClass · 0.90
boxMethod · 0.80
cylinderMethod · 0.80
centerMethod · 0.80
importStepMethod · 0.80
sizeMethod · 0.45
solidsMethod · 0.45

Tested by

no test coverage detected