draw.Drawing.print
draw.Drawing: print (D, FILE)
draw.Drawing: print (D, FILE, NAME, VALUE, …)
draw.Drawing: [PAPER, SCALE] = print (…)
Plot a drawing onto paper at a stated scale.
draw.Drawing.print (D, FILE) writes the
draw.Drawing object D to FILE on an A4 landscape
sheet, at the largest of the preferred scales that fits. The output
format is taken from the extension of FILE: .pdf,
.eps and .svg are vector, .png, .jpg and
.tif are raster.
The drawing arrives at its scale, not merely fitted to the
page. A distance measured on the sheet, multiplied by the scale
denominator, is the distance in the model. That is the difference
between a plot and a picture, and it is what print on a figure
cannot give: it fits the axes to the paper, so a millimetre on the page
means nothing.
| Name | Default | Meaning |
|---|---|---|
'Paper' | 'A4' | sheet, named 'A0' to
'A5', or [width, height] in millimetres |
'Orientation' | 'landscape' | or
'portrait'; ignored when 'Paper' is given as a size |
'Scale' | fitted | plot scale denominator: 50 means 1:50. The default picks the largest preferred scale the sheet holds |
'Margin' | 10 | blank border kept around the drawing,
in millimetres of paper; 0 for none, as a sheet framed by
draw.titleblock wants, since its frame runs along the trimmed
edge of the paper |
'Resolution' | 600 | dots per inch, for a raster format only; a vector format ignores it |
'LineWidth' | 0.35 | pen width in millimetres of paper, from the ISO 128 set 0.25, 0.35, 0.5, 0.7, for every line with no line weight of its own or of its layer |
A layer whose plot is false in Layers is left off the
paper, as is a layer that is not visible, but a layer not printed keeps
its place on the sheet: the trimmed edge draw.titleblock draws
on such a layer still places the sheet on the paper.
[PAPER, SCALE] = draw.Drawing.print (…) returns
the sheet size actually used, in millimetres, and the scale denominator,
which is worth having when the scale was fitted rather than given.
Printing needs the qt or gnuplot graphics toolkit.
fltk, which octave-cli uses on a desktop, cannot print
a figure that is not shown, so there print is an error; run
Octave as octave --no-gui, or call
graphics_toolkit ('gnuplot') first.
When 'Scale' is not given, the denominator is the smallest of
1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000 that leaves
the drawing inside the sheet’s margins. Those are the scales ISO 5455
admits, so an automatically chosen scale is still one a reader expects
to see in a title block, rather than the 1:37.4 that fitting exactly
would give.
An explicit 'Scale' is never overridden. If the drawing does not
fit at it, that is an error rather than a silent reduction: a sheet at
the wrong scale is worse than no sheet.
Each string is drawn at the height its entity carries, reduced by the
scale, exactly as draw.Drawing.tikz does and as a CAD application
does: lettering given as 125 mm in the model arrives 2.5 mm tall on a
sheet at 1:50. Author it as the height wanted on paper times the scale
denominator. The height is therefore part of the drawing and survives
into a file written from it, rather than being a property of one
particular plot.
'LineWidth' is the opposite: a width on the paper, held there at
every scale, because a 0.35 mm pen is 0.35 mm whatever the sheet shows.
So are the dashes of a line type and the ticks and labels of a
dimension: they arrive at their nominal size on the sheet whatever the
scale, as draw.Drawing.plot draws them with 'LTScale' and
'DimScale' set to the scale denominator.
See also: draw.Drawing.plot, draw.Drawing.tikz, draw.titleblock, draw.Drawing.write
Source Code: draw.Drawing
A plate plotted on A4 at a scale the sheet chooses. What comes back is the sheet actually used and the scale it settled on, which is what a title block has to state.
D = draw.Drawing ('plate');
D = D.polyline (geom.Polyline ([0, 0; 200, 0; 200, 120; 0, 120], ...
'Closed', true));
D = D.circle ([100, 60], 35);
D = D.dim ([0, 0], [200, 0], -20, 'horizontal');
fn = fullfile (tempdir (), 'plate.pdf');
[paper, scale] = print (D, fn)
paper = 297 210 scale = 1
delete (fn);
The same drawing on A5 needs a smaller scale, and the function picks the largest of the ISO 5455 series that still fits rather than an exact fit.
PL = geom.Polyline ([0, 0; 200, 0; 200, 120; 0, 120], 'Closed', true); D = draw.Drawing ().polyline (PL); fn = fullfile (tempdir (), 'plate5.pdf'); [paper, scale] = print (D, fn, 'Paper', 'A5')
paper = 210 148 scale = 2
delete (fn);