SaveToFile
Saves an object to a file-system file.
Syntax
-
SaveToFile(X[, fn[, options ...]])
-
X
is any object -
fn
is a string -
options ...
is any number of options of the form"name": value
-
Description
If X
is any object and fn
a valid, fully-qualified file name, then SaveToFile(X, fn)
saves X
to the file given by fn
, overwriting any already existing file with this path and name.
The type and format of file created depends on the type of X
:
-
Pixmaps are saved as raster image files. The file format is determined by the extension part of
fn
. Allowed extensions are.bmp
,.png
,.gif
, and.jpg
. -
Sounds are saved as PCM waveform audio files. Sample rate and bit depth are the same as in
X
. -
Binary data objects are saved as binary files.
-
If
X
is a reference to a visual object, the diagram or scene containing the visual object is saved as a Scalable Vector Graphics (SVG) or raster graphics image file. -
For all other types,
string(X)
is saved as a text file.
If the file name is omitted, a standard dialog box is shown prompting for a file name.
If X
is a reference to a 2D visual object, the following SVG export options may be specified:
-
width
: a valid SVG length string (e.g. "60", "10cm", or "100%") -
height
: a valid SVG length string -
stretch
: a boolean -
title
: a string -
description
: a string
If one of width
and height
is specified – but not both – the other will automatically be chosen in such a way that the aspect ratio is preserved. If both are left unspecified, the diagram’s current or last on-screen size is used. If both are specified, they determine the size of the SVG image. However, the SVG will be scaled proportionally, respecting its aspect ratio, unless stretch
is explicitly set to true
.
If X
is a reference to a 3D visual object, width
and height
may be specified as integers.
export
is a synonym for SaveToFile
.