Exports a box with unit="M" and outputUnit="M". This should prevent OCCT from scaling the object from MM to M when it is written to the STEP file. Re-importing should return the original 10x10x10 box.
(tmpdir)
| 1006 | |
| 1007 | |
| 1008 | def test_step_export_output_unit(tmpdir): |
| 1009 | """ |
| 1010 | Exports a box with unit="M" and outputUnit="M". This should prevent |
| 1011 | OCCT from scaling the object from MM to M when it is written to the |
| 1012 | STEP file. Re-importing should return the original 10x10x10 box. |
| 1013 | """ |
| 1014 | box_path = os.path.join(tmpdir, "output_unit_roundtrip.step") |
| 1015 | Workplane().box(10, 10, 10).val().exportStep(box_path, unit="M", outputUnit="M") |
| 1016 | |
| 1017 | # Make sure the coordinates are what we expect |
| 1018 | with open(box_path, "r") as f: |
| 1019 | content = f.read() |
| 1020 | assert "CARTESIAN_POINT('',(-5.,-5.,-5.));" in content |
| 1021 | |
| 1022 | # Make sure the units are set correctly |
| 1023 | assert "MILLI" not in content |
| 1024 | assert "METRE" in content |
| 1025 | |
| 1026 | imported = importers.importStep(box_path, unit="m") |
| 1027 | bb = imported.val().BoundingBox() |
| 1028 | |
| 1029 | assert bb.xlen == approx(10.0, rel=1e-3) |
| 1030 | assert bb.ylen == approx(10.0, rel=1e-3) |
| 1031 | assert bb.zlen == approx(10.0, rel=1e-3) |
| 1032 | |
| 1033 | |
| 1034 | def test_toVTK(): |
nothing calls this directly
no test coverage detected