Simple shape vrml export

This commit is contained in:
adam-urbanczyk
2020-10-14 19:01:01 +02:00
parent 6f8aca8299
commit 36ce899dfe

View File

@ -5,6 +5,8 @@ import io as StringIO
from typing import IO, Optional, Union, cast from typing import IO, Optional, Union, cast
from typing_extensions import Literal from typing_extensions import Literal
from OCP.VrmlAPI import VrmlAPI
from ...cq import Workplane from ...cq import Workplane
from ...utils import deprecate from ...utils import deprecate
from ..shapes import Shape from ..shapes import Shape
@ -23,9 +25,10 @@ class ExportTypes:
SVG = "SVG" SVG = "SVG"
TJS = "TJS" TJS = "TJS"
DXF = "DXF" DXF = "DXF"
VRML = "VRML"
ExportLiterals = Literal["STL", "STEP", "AMF", "SVG", "TJS", "DXF"] ExportLiterals = Literal["STL", "STEP", "AMF", "SVG", "TJS", "DXF", "VRML"]
def export( def export(
@ -98,6 +101,10 @@ def export(
elif exportType == ExportTypes.STL: elif exportType == ExportTypes.STL:
shape.exportStl(fname, tolerance, angularTolerance) shape.exportStl(fname, tolerance, angularTolerance)
elif exportType == ExportTypes.VRML:
shape.mesh(tolerance, angularTolerance)
VrmlAPI.Write_s(shape.wrapped, fname)
else: else:
raise ValueError("Unknown export type") raise ValueError("Unknown export type")