viewer.export — device scene export
tempura/viewer/export.py serializes a finalized device into the bundle consumed
by the standalone TypeScript 3D viewer. export_device_view(...) writes one
scene.json metadata file plus binary array assets holding the layer height
fields and gate stencils.
What it writes
For each layer the exporter records the realized bottom/top height fields, and
for gates the stencil, as little-endian binary arrays referenced from
scene.json (see viewer._bundle_io). Per-layer colors
can be overridden. The returned DeviceViewExportManifest lists the scene file
and every asset written, so callers can track or relocate the bundle.
The device must be finalized — the export reads the realized height arrays that
finalize() produces.
API
export
Export finalized device geometry for the standalone TypeScript viewer.
DeviceViewExportManifest
dataclass
Paths written by :func:export_device_view.
Attributes:
| Name | Type | Description |
|---|---|---|
scene_name |
str
|
Human-readable scene name stored in |
scene_json_path |
Path
|
Path to the scene metadata file. |
asset_paths |
tuple[Path, ...]
|
Paths to binary array assets referenced by |
Source code in tempura/viewer/export.py
26 27 28 29 30 31 32 33 34 35 36 37 38 | |
export_device_view(device, out_dir, *, scene_name='device', colors=None, overwrite=True, verbose=False)
Export a device into files consumed by the TypeScript 3D viewer.
The exporter writes one scene.json metadata file and one or more binary
array files storing layer height fields (plus gate stencils).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Device
|
Device to export. |
required |
out_dir
|
str | Path
|
Output directory for the exported scene bundle. |
required |
scene_name
|
str
|
Label stored in the metadata file. |
'device'
|
colors
|
dict[str, str] | None
|
Optional per-layer color overrides keyed by layer name. |
None
|
overwrite
|
bool
|
If |
True
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
DeviceViewExportManifest
|
Manifest describing the files written. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the device is empty or a color override is invalid. |
FileExistsError
|
If |
RuntimeError
|
If the device is not finalized or finalized height arrays are missing. |
Source code in tempura/viewer/export.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |