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

Function test_fused_assembly_top_level_with_children

tests/test_exporters.py:237–262  ·  view source on GitHub ↗

Tests the assembly with a top level shape and multiple children. The resulting STEP is imported again to test it.

(tmpdir)

Source from the content-addressed store, hash-verified

235
236
237def test_fused_assembly_top_level_with_children(tmpdir):
238 """
239 Tests the assembly with a top level shape and multiple children.
240 The resulting STEP is imported again to test it.
241 """
242
243 # Create the assembly
244 body = Workplane().box(10, 10, 10)
245 assy = Assembly(body)
246 mark = Workplane().center(3, 3).cylinder(radius=1, height=10)
247 assy.add(mark, color=Color(1, 0, 0), name="mark")
248 pin = Workplane().center(-5, -5).cylinder(radius=2, height=20)
249 assy.add(pin, loc=Location(Vector(0, 0, 15)), color=Color(0, 1, 0), name="pin")
250
251 # Export the assembly
252 step_path = os.path.join(tmpdir, "top_level_with_children_fused_assembly.step")
253 assy.save(
254 path=str(step_path),
255 exportType=exporters.ExportTypes.STEP,
256 mode=exporters.assembly.ExportModes.FUSED,
257 )
258
259 # Import the assembly and make sure it acts as expected
260 model = importers.importStep(step_path)
261 assert model.solids().size() == 1
262 assert model.faces(">Z").val().Center().z == approx(25)
263
264
265def test_fused_empty_assembly(tmpdir):

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected