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

Function test_step_export_output_unit

tests/test_exporters.py:1008–1031  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1006
1007
1008def 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
1034def test_toVTK():

Callers

nothing calls this directly

Calls 6

WorkplaneClass · 0.90
exportStepMethod · 0.80
boxMethod · 0.80
importStepMethod · 0.80
valMethod · 0.45
BoundingBoxMethod · 0.45

Tested by

no test coverage detected