Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cadquery/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ def export(

if exportType is None:
t = path.split(".")[-1].upper()
if t == "WRL":
t = "VRML"
if t in ("STEP", "XML", "XBF", "VRML", "VTKJS", "GLTF", "GLB", "STL"):
exportType = cast(ExportLiterals, t)
else:
Expand Down
2 changes: 2 additions & 0 deletions cadquery/occ_impl/exporters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def export(

if exportType is None:
t = fname.split(".")[-1].upper()
if t == "WRL":
t = ExportTypes.VRML
if t in ExportTypes.__dict__.values():
exportType = cast(ExportLiterals, t)
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ def test_toJSON(simple_assy, empty_top_assy):
("xml", ()),
("stp", ("STEP",)),
("caf", ("XML",)),
("wrl", ("VRML",)),
("wrl", ()),
("stl", ("STL",)),
],
)
Expand All @@ -1464,7 +1464,7 @@ def test_save(extension, args, nested_assy, tmpdir):
("stl", (), {"ascii": True}),
("stp", ("STEP",), {}),
("caf", ("XML",), {}),
("wrl", ("VRML",), {}),
("wrl", (), {}),
("stl", ("STL",), {}),
],
)
Expand Down
10 changes: 6 additions & 4 deletions tests/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,14 @@ def testTJS(self):

def testVRML(self):

exporters.export(self._box(), str(self.tmpdir / "out1.vrml"))
for extension in ("vrml", "wrl"):
output = self.tmpdir / f"out1.{extension}"
exporters.export(self._box(), str(output))

with open(self.tmpdir / "out1.vrml") as f:
res = f.read(10)
with open(output) as f:
res = f.read(10)

assert res.startswith("#VRML V2.0")
assert res.startswith("#VRML V2.0")

# export again to trigger all paths in the code
exporters.export(self._box(), str(self.tmpdir / "out2.vrml"))
Expand Down