draw.Drawing

Methods

Method Reference: 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/Value pairs

NameDefaultMeaning
'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'fittedplot scale denominator: 50 means 1:50. The default picks the largest preferred scale the sheet holds
'Margin'10blank border kept around the drawing, in millimetres of paper
'Resolution'600dots per inch, for a raster format only; a vector format ignores it
'LineWidth'0.35pen width in millimetres of paper, from the ISO 128 set 0.25, 0.35, 0.5, 0.7

Source Code: draw.Drawing

[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.

The scale is chosen from the preferred series

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.

Text is a model dimension, pens are a paper one

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 the DXF, 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.

See also: draw.Drawing.plot, draw.Drawing.tikz, draw.titleblock, dxf.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 ([0, 0; 200, 0; 200, 120; 0, 120], 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.

 D = draw.Drawing ().polyline ([0, 0; 200, 0; 200, 120; 0, 120], true);
 fn = fullfile (tempdir (), 'plate5.pdf');
 [paper, scale] = print (D, fn, 'Paper', 'A5')
paper =

   210   148

scale = 2
 delete (fn);