hertzforge.io.exporters¶
exporters
¶
The exporter registry.
Most formats Hertzforge can read, it can also write (the exceptions are listed in docs/export.md), so that data read here can be passed on to the next tool in the same format. Exporters are registered the same way importers are, and each says which objects it can write.
Values are written in the unit system asked for, which the app takes from the display selector, so a file holds the numbers shown on screen. With no system given, they are written as stored: SI once units are declared.
A format with no place to record units is written in the display system
itself, g included: in-slinch-lbf-s (g) writes accelerations in g. The
file cannot say so, and choosing a display system that suits whatever
reads the file next is the user's call (Brandon, 2026-11-18). A format
that records its units writes a system it can declare: UNV's units block
carries length, force and temperature factors and nothing else, so UNV
writes the coherent system the display system is built on (in/s² for
in-slinch-lbf-s (g)); Nastran and ADF are SI and 3MF is meters.
units_written says how each one did, for the line the app shows after
a save.
An object whose units are unknown is written exactly as it stands. There is no factor to convert it by.
Classes:
| Name | Description |
|---|---|
Exporter |
One format Hertzforge can write. |
Functions:
| Name | Description |
|---|---|
register_exporter |
Add a format to the exporters. |
exporters |
Every exporter in registration order, or only those that can |
units_written |
The units a file of |
geometry_values |
(coordinates, coordinate system matrices) in |
data_values |
(abscissa, ordinate) in |
shape_values |
Mode shape coefficients in the mass unit of |
export_file |
Write |
Classes¶
Exporter
dataclass
¶
One format Hertzforge can write.
handles(obj) says whether this exporter can write that object,
which is how the Export menu lists only the formats that apply,
and save(obj, path, unit_system=..., **kwargs) writes it.
suffix is the file suffix that selects this exporter when no
format is named.
Functions:¶
register_exporter
¶
register_exporter(name: str, description: str, suffix: str, handles: Callable, save: Callable) -> None
Add a format to the exporters.
When export_file chooses by suffix, the first registered exporter
that can write the object and matches the suffix is used, so of two
exporters with one suffix the one registered first is the default.
exporters
¶
exporters(obj: Any = None) -> list[Exporter]
Every exporter in registration order, or only those that can
write obj when it is given.
units_written
¶
units_written(format: str, unit_system: UnitSystem) -> str
The units a file of format holds its values in when saved with
unit_system chosen, in words.
The status line shows this after a save, because most formats do not record it themselves. UNV declares the coherent system the display system is built on, since its units block cannot hold g; Nastran and ADF files are SI; 3MF is in meters; ESCDF labels each value with the unit it was declared in; every other format is in the display system itself, g included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
An exporter's name ( |
required |
unit_system
|
UnitSystem
|
The display system the save was asked for. |
required |
Returns:
| Type | Description |
|---|---|
str
|
For example 'in-slinch-lbf-s', 'SI', or 'the units each object was declared in'. |
geometry_values
¶
geometry_values(geometry: Geometry, unit_system: UnitSystem | None) -> tuple[ndarray, ndarray]
(coordinates, coordinate system matrices) in unit_system, or as stored when it is None or the geometry has no
units defined.
Only the origin row of a coordinate system matrix has length; its axes are directions and are not changed.
data_values
¶
data_values(data: DataArray, unit_system: UnitSystem | None) -> tuple[ndarray, ndarray]
(abscissa, ordinate) in unit_system, g included, or as
stored when it is None or the data has no units defined.
shape_values
¶
shape_values(shapes: ShapeSet, unit_system: UnitSystem | None) -> ndarray
Mode shape coefficients in the mass unit of unit_system, or as stored when it is None or the shapes have no
units defined.
The shapes are mass normalized, so they scale by 1/sqrt(mass), the inverse of the factor that converted them to 1/sqrt(kg).
export_file
¶
export_file(obj: Any, path: str | PathLike, format: str | None = None, unit_system: UnitSystem | None = None, **kwargs: Any) -> None
Write obj to a file in a format chosen by name or by suffix.
unit_system is the system to write in; without one the stored
values are written as they are. When no exporter can write the
object to that format, the ValueError lists the formats it can be
written as, since the fix is nearly always a different format. A
ValueError is also raised when a format that writes DOFs as node
numbers (UNV, ADF functions and time histories, Exodus, the sdynpy
data array) is asked to write modal coordinates. A leading ~ in
the path is expanded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
What to write: a geometry, data, shapes, a project, and so on. |
required |
path
|
str or PathLike
|
Where; the suffix picks the format when |
required |
format
|
str
|
An exporter by name ( |
None
|
unit_system
|
UnitSystem
|
The units to write in; the stored values as they are when omitted. |
None
|
**kwargs
|
Any
|
Passed to the format's writer, e.g. an ESCDF file's |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
|