MCPcopy Index your code
hub / github.com/CadQuery/cadquery / test_assembly_import_step_unit

Function test_assembly_import_step_unit

tests/test_assembly.py:1355–1375  ·  view source on GitHub ↗

Exports an assembly labeled as meters and re-imports it via Assembly.importStep. The geometry should be scaled to mm on import.

(tmp_path_factory)

Source from the content-addressed store, hash-verified

1353
1354
1355def test_assembly_import_step_unit(tmp_path_factory):
1356 """
1357 Exports an assembly labeled as meters and re-imports it via
1358 Assembly.importStep. The geometry should be scaled to mm on import.
1359 """
1360
1361 tmpdir = tmp_path_factory.mktemp("unit_assy_import")
1362 m_path = os.path.join(tmpdir, "assy_import_meters.step")
1363
1364 assy = cq.Assembly()
1365 assy.add(cq.Workplane().box(1, 1, 1), name="box")
1366 exportAssembly(assy, m_path, unit="M")
1367
1368 imported = cq.Assembly.importStep(m_path, unit="M")
1369 assert imported is not None
1370
1371 # The shape should be 1.0x1.0x1.0 mm since OCCT converts from meters
1372 bb = imported.toCompound().BoundingBox()
1373 assert bb.xlen == approx(1.0, rel=1e-3)
1374 assert bb.ylen == approx(1.0, rel=1e-3)
1375 assert bb.zlen == approx(1.0, rel=1e-3)
1376
1377
1378@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

addMethod · 0.95
exportAssemblyFunction · 0.90
boxMethod · 0.80
importStepMethod · 0.80
toCompoundMethod · 0.80
BoundingBoxMethod · 0.45

Tested by

no test coverage detected