Source code for pyvcad_rendering.export
import os
import wx
from .render import _get_caller_id
[docs]
def export(vcad_object, materials=None):
"""Open the interactive compiler export dialog for ``vcad_object`` (wx main loop).
The dialog lists every ``pyvcad_compilers`` compiler, shows which attributes
the design provides (authored or computed by converters) and which each
compiler needs, and greys out the ones the design cannot feed. Pick a
compiler, adjust its validated settings, and export with live progress and
cancel. Outputs default to an ``output/`` folder next to the calling script.
Arguments:
vcad_object (Node): The design root.
materials (MaterialDefs, optional): Material definitions for the design.
Defaults to ``pyvcad.default_materials``.
"""
from .export_catalog import ExportDefaults
from .export_frame import ExportFrame
caller_id = _get_caller_id()
if caller_id != "unknown" and os.path.isfile(caller_id):
output_root = os.path.join(os.path.dirname(caller_id), "output")
stem = os.path.splitext(os.path.basename(caller_id))[0]
else:
output_root = os.path.join(os.getcwd(), "output")
stem = "design"
with wx.LogNull():
app = wx.GetApp() or wx.App(False)
ExportFrame(vcad_object, materials, caller_id=caller_id, defaults=ExportDefaults(output_root, stem))
app.MainLoop()
[docs]
def Export(vcad_object, materials=None):
"""Alias for :func:`export`."""
export(vcad_object, materials)
__all__ = ["export", "Export"]