visualdynamics.io.exporters¶
exporters
¶
The exporter registry.
Most formats Visual Dynamics 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 display system that shows acceleration in g writes the coherent system
it is built on (in/s² for in-slinch-lbf-s (g)), because most formats
cannot label a value as g: UNV's units block, for one, carries length,
force and temperature factors and nothing else. A few formats write
their own way, and 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 Visual Dynamics 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 the coherent form of |
data_values |
(abscissa, ordinate) in the coherent form of |
shape_values |
Mode shape coefficients in the mass unit of the coherent form of |
export_file |
Write |
Classes¶
Exporter
dataclass
¶
One format Visual Dynamics 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.
Source code in src/visualdynamics/io/exporters.py
exporters
¶
exporters(obj: Any = None) -> list[Exporter]
Every exporter in registration order, or only those that can
write obj when it is given.
Source code in src/visualdynamics/io/exporters.py
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. A .mat, a delimited-text .csv and a
controller's random specification are in the display system itself,
g included; 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 coherent system the display system is built on.
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'. |
Source code in src/visualdynamics/io/exporters.py
geometry_values
¶
geometry_values(geometry: Geometry, unit_system: UnitSystem | None) -> tuple[ndarray, ndarray]
(coordinates, coordinate system matrices) in the coherent form of
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.
Source code in src/visualdynamics/io/exporters.py
data_values
¶
data_values(data: DataArray, unit_system: UnitSystem | None) -> tuple[ndarray, ndarray]
(abscissa, ordinate) in the coherent form of unit_system, or as
stored when it is None or the data has no units defined.
Source code in src/visualdynamics/io/exporters.py
shape_values
¶
shape_values(shapes: ShapeSet, unit_system: UnitSystem | None) -> ndarray
Mode shape coefficients in the mass unit of the coherent form 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).
Source code in src/visualdynamics/io/exporters.py
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
|
|