Files
cadcraft/docs/plot-styles.md
2026-12-02 14:47:05 -07:00

9.5 KiB
Raw Permalink Blame History

Plot styles

A plot style table decides how objects print. CADCraft applies it to PDF plots (PLOT, EXPORTPDF and anything that plots through them). It also applies it to a layout shown with Display plot styles on: on screen and in the layout's PNG and SVG exports.

Tables

Kind Picks the style by Styles
Colour-dependent (.ctb) the object's index colour (a true colour uses its nearest index colour, but the style's color does not replace it) exactly 255, Color_1 … Color_255
Named (.stb) the object's PlotStyle property Normal first, then any names

A style can set these:

Field Meaning "Use object" value
color output colour, "#rrggbb" absent / null
grayscale print the colour as the grey of its luminance (Rec. 709 weights) false
screening ink intensity 0–100 %, mixing toward the white paper 100
linetype linetype name (loaded, or from the built-in library; Continuous draws solid) absent / null
lineweight hundredths of a millimetre, 0–211; used when lineweights are plotted absent / null
end, join, fill line end, line join and area fill style object

Colour 7 prints black.

An object with a true colour, its own or its layer's, is not given the color of a colour-dependent table's style: that colour is for index colours. So through a table that prints every colour black a true colour still prints in its own colour, and true white stays white and still hides what is under it. The other fields of the nearest index colour's style (grayscale, screening, linetype, lineweight, end, join, fill) apply to it.

Line ends, joins and fill patterns

  • end and join shape lines wider than 0.25 mm on paper (from lineweights). The line is drawn as its filled outline: butt ends at the end point, square reaches half the width past it, round adds a half circle and diamond a point. miter joins meet in a point (bevelled past 10 half widths), bevel cuts the corner, round rounds it and diamond points out one half width. object is round, as lines are drawn anyway.
  • fill replaces the solid fill of filled areas: 2D solids, traces, wide polylines, solid hatches and filled text. solid and object keep it solid. The patterns are CADCraft's own definitions, measured on paper and anchored to the sheet's origin. They repeat every 1 mm:
Fill Pattern
checkerboard 0.5 mm squares, every other one filled
crosshatch horizontal and vertical bars, 0.2 mm wide
diamonds 0.35 mm squares turned 45°, every 0.7 mm
horizontalBars, verticalBars bars a third of the repeat wide
slantLeft, slantRight \ and / bars a third of the repeat wide
squareDots 0.2 mm squares every 0.5 mm

Wipeouts are never patterned. A plot that would need more than two million pattern cells keeps the remaining areas solid. Layouts draw these while the display list is built. A model-space plot draws them at its plot scale.

Built-in tables

These are CADCraft's own definitions, not copies of any vendor's files.

Table What it does
default.ctb keeps every object property
monochrome.ctb prints every colour black
grayscale.ctb prints every colour as the grey of its luminance
default.stb Normal (object properties), Black, Screened 50%, Thick (0.50 mm)
monochrome.stb Normal prints black; Screened 50% prints black at 50 %

A table kept in the drawing shadows a built-in table of the same name.

The plot styles folder

Tables can also be kept as files on the computer, so every drawing can use them. The folder is plotstyles in the CADCraft settings folder (CADCRAFT_CONFIG_DIR, else ~/Library/Application Support/CADCraft on macOS, %APPDATA%\CADCraft on Windows and ~/.config/cadcraft on Linux). The web build keeps them for the session.

  • Each table is one file in the format below, named after the table plus .json: studio.ctb.json holds studio.ctb. The file name wins over the name inside, so renaming the file renames the table. A file without .ctb/.stb gets its kind's ending; a file whose ending doesn't match its kind is skipped, as is any file we can't read. Saving a change to a table moves it to the file named after it (studio.json becomes studio.ctb.json). The first 1000 files by name are read. STYLESMANAGER list reports the skipped files in warnings.
  • The folder is read when CADCraft starts and each time the Plot Style Manager opens.
  • A layout that chooses a folder table takes a copy of it into the drawing. From then on the drawing plots with its copy: editing, renaming or deleting the file doesn't change it, and the drawing plots the same on a computer without the file. Choosing the table again keeps the copy the drawing has.
  • A plot (not a preview) with a folder table also takes a copy into the drawing.
  • Model keeps one page setting of its own, its plot style table: a plot from Model, Apply to Layout in the Plot dialog, or the Properties palette in Model remember it in the drawing (pagesetup with layout: "Model" and only plotStyleTable), and the next Model plot starts from it. It is saved in the DXF with Model's page setup.
  • Saving to DWG or DXF also copies into the drawing any folder table a layout or Model uses that it doesn't have yet, so the saved file always carries every table it needs.
  • A table is looked up in the drawing first, then in the folder, then among the built-in ones. The Plot Style Manager lists a name the drawing and the folder both have twice, once for each.
  • Changes to the folder are written at once and can't be undone; changes to the drawing's tables can.

Named plot styles

Layers have a plot style name (default Normal). Objects have ByLayer (the default), ByBlock or a style name. ByLayer takes the layer's style. On layer 0 inside a block, that is the block reference's layer. ByBlock takes the block reference's style. A name the table doesn't have prints as Normal. A colour-dependent table ignores the property.

Commands

  • pagesetup {layout, plotStyleTable, displayPlotStyles} sets the layout's table and the Display plot styles flag. Without a layout, it reports the built-in tables in plotStyleTables.
  • plot / exportpdf {plotStyleTable} replaces the page setup's table for one plot. "None" plots object colours.
  • plotstyle {name, handles?} sets the objects' plot style. With nothing selected, it sets the current plot style for new objects (CPLOTSTYLE). Without name, it reports the current style and the named styles.
  • layer.set {name, plotStyle} sets a layer's plot style.
  • stylesmanager {action, …} manages the tables: list (each table's source: folder, drawing or builtin; the folder's place in folder), get, new (kind, from, fromWhere, description, where), set (style: {name, …fields}, removeStyle, description; it replies with the table's name and only what changed; where: folder writes the folder's file), rename (to), delete (where), load (path or text, where), save (path, or returns text) and reload (read the folder again). where is folder or drawing: new and load default to the drawing; get, set, rename and delete to the drawing's table, else the folder's file. Renaming the file leaves the drawings' copies and layouts as they are; renaming the drawing's table moves its layouts. Typed or chosen from File ▸ Plot Styles..., it opens the Plot Style Manager dialog. Its New... window asks the name, the kind, the table to start from, a description and where to save it; Rename... and Delete... work on the folder's file or the drawing's table, and the folder's place is shown at the bottom, with Open folder to show it in the system's file manager.

Table files

Tables are saved in our own format: UTF-8 JSON with a format marker. Fields left at "use the object's" are omitted.

{
  "cadcraftPlotStyleTable": 1,
  "name": "office.stb",
  "description": "Office pens",
  "kind": "named",
  "styles": [
    { "name": "Normal" },
    { "name": "Pen 5", "color": "#000000", "screening": 40, "lineweight": 35, "linetype": "HIDDEN", "end": "round" }
  ]
}
  • kind is colorDependent or named.
  • end is one of object, butt, square, round or diamond.
  • join is one of object, miter, bevel, round or diamond.
  • fill is one of object, solid, checkerboard, crosshatch, diamonds, horizontalBars, slantLeft, slantRight, squareDots or verticalBars.
  • color may also be written [r, g, b].

Reading fixes hostile values:

  • Screening is capped at 100 and lineweights at 211.
  • A colour-dependent table always gets 255 styles named Color_n.
  • A named table gets unique style names (at most 1024), with Normal first.
  • Files over 4 MB are refused.

Binary .ctb/.stb files are not read. We haven't found a public specification of that format.

In DXF files

  • The page setup's table is PLOTSETTINGS group 7, and Display plot styles is plot layout flag 2 (group 70).
  • Plot style names follow the DXF Reference. The named object dictionary entry ACAD_PLOTSTYLENAME is an ACDBDICTIONARYWDFLT whose entries name ACDBPLACEHOLDER objects (default Normal). Layers and objects point at them with group 390. An object without a 390 is ByLayer. ByBlock isn't written, so it reads back as ByLayer.
  • Tables kept in the drawing travel in the CADCRAFT_PLOTSTYLES XRECORD (JSON) of the named object dictionary.