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)
| 1353 | |
| 1354 | |
| 1355 | def 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( |
nothing calls this directly
no test coverage detected