Exporters#
An exporter writes SAMSON content to an external file format.
Use an exporter when your extension should turn data graph content into a file that can be archived, exchanged with another tool, or consumed by a downstream workflow.
Typical examples include structure writers, mesh exporters, trajectory snapshots, and tool-specific exchange formats.
Key class and core responsibilities#
File exporters derive from SBIFileExporter.
An exporter should:
- declare the target file extension through
SBIFileExporter::getExtension - provide a user-facing file dialog filter through
SBIFileExporter::getFilter - implement
exportToFileto serialize the relevant nodes
How exporters are used#
An exporter may be used:
- from the SAMSON UI when the user exports a file
- programmatically via
SAMSON::exportToFile
In both cases, SAMSON can route the request to the exporter matching the chosen file extension.
What to think about when designing an exporter#
The main design question is what subset of the data graph should be represented in the external format.
A good exporter defines:
- which node types it supports
- what happens when unsupported nodes are present
- how scientific metadata is preserved, approximated, or omitted
- whether the exporter writes the entire selection or a reduced representation
If the format cannot represent the full SAMSON object graph, document the loss clearly.
Example scenario#
Suppose you need to export a selected nanostructure to a simulation package:
- the exporter collects the selected nodes
- it extracts the subset of properties required by the target format
- it writes the target file while validating units, identifiers, and topology assumptions
That is exporter logic, even if you also provide an app to choose additional export options.
What to read next#
- Use Extension Generator to scaffold an exporter.
- Read Importers if you also need the reverse path.
- Read Getting nodes when you need precise node collection logic before writing a file.