Plot Style Files (CTB/STB)

CTB and STB files store plot styles used by AutoCAD and BricsCAD for printing and plotting.

If the plot style table is attached to a Paperspace or the Modelspace, a change of a plot style affects any object that uses that plot style. CTB files contain color dependent plot style tables, STB files contain named plot style tables.

See also

ezdxf.addons.acadctb.load(filename: str) → Union[ColorDependentPlotStyles, NamedPlotStyles]

Load the CTB or STB file filename from file system.

ezdxf.addons.acadctb.new_ctb() → ColorDependentPlotStyles

Create a new CTB file.

Changed in version 0.10: renamed from new()

ezdxf.addons.acadctb.new_stb() → NamedPlotStyles

Create a new STB file.

ColorDependentPlotStyles

Color dependent plot style table (CTB file), table entries are PlotStyle objects.

class ezdxf.addons.acadctb.ColorDependentPlotStyles
description

Custom description of plot style file.

scale_factor

Specifies the factor by which to scale non-ISO linetypes and fill patterns.

apply_factor

Specifies whether or not you want to apply the scale_factor.

custom_lineweight_display_units

Set 1 for showing lineweight in inch in AutoCAD CTB editor window, but lineweights are always defined in millimeters.

lineweights

Lineweights table as array.array

__getitem__(aci: int) → PlotStyle

Returns PlotStyle for AutoCAD Color Index (ACI) aci.

__iter__() → Iterable[PlotStyle]

Iterable of all plot styles.

new_style(aci: int, data: dict = None) → PlotStyle

Set aci to new attributes defined by data dict.

Parameters:
  • aciAutoCAD Color Index (ACI)
  • datadict of PlotStyle attributes: description, color, physical_pen_number, virtual_pen_number, screen, linepattern_size, linetype, adaptive_linetype, lineweight, end_style, join_style, fill_style
get_lineweight(aci: int)

Returns the assigned lineweight for PlotStyle aci in millimeter.

get_lineweight_index(lineweight: float) → int

Get index of lineweight in the lineweight table or append lineweight to lineweight table.

get_table_lineweight(index: int) → float

Returns lineweight in millimeters of lineweight table entry index.

Parameters:index – lineweight table index = PlotStyle.lineweight
Returns:lineweight in mm or 0.0 for use entity lineweight
set_table_lineweight(index: int, lineweight: float) → int

Argument index is the lineweight table index, not the AutoCAD Color Index (ACI).

Parameters:
save(filename: str) → None

Save CTB file as filename to the file system.

write(stream: BinaryIO) → None

Compress and write CTB file to binary stream.

NamedPlotStyles

Named plot style table (STB file), table entries are PlotStyle objects.

class ezdxf.addons.acadctb.NamedPlotStyles
description

Custom description of plot style file.

scale_factor

Specifies the factor by which to scale non-ISO linetypes and fill patterns.

apply_factor

Specifies whether or not you want to apply the scale_factor.

custom_lineweight_display_units

Set 1 for showing lineweight in inch in AutoCAD CTB editor window, but lineweights are always defined in millimeters.

lineweights

Lineweights table as array.array

__getitem__(name: str) → PlotStyle

Returns PlotStyle by name.

__delitem__(name: str)

Delete plot style name. Plot style 'Normal' is not deletable.

__iter__() → Iterable[str]

Iterable of all plot style names.

new_style(name: str, localized_name: str = None, data: dict = None) → PlotStyle

Create new class:PlotStyle name by attribute dict data, replaces existing class:PlotStyle objects.

Parameters:
  • name – plot style name
  • localized_name – name shown in plot style editor, uses name if None
  • datadict of PlotStyle attributes: description, color, physical_pen_number, virtual_pen_number, screen, linepattern_size, linetype, adaptive_linetype, lineweight, end_style, join_style, fill_style
get_lineweight(name: str)

Returns the assigned lineweight for PlotStyle name in millimeter.

get_lineweight_index(lineweight: float) → int

Get index of lineweight in the lineweight table or append lineweight to lineweight table.

get_table_lineweight(index: int) → float

Returns lineweight in millimeters of lineweight table entry index.

Parameters:index – lineweight table index = PlotStyle.lineweight
Returns:lineweight in mm or 0.0 for use entity lineweight
set_table_lineweight(index: int, lineweight: float) → int

Argument index is the lineweight table index, not the AutoCAD Color Index (ACI).

Parameters:
save(filename: str) → None

Save STB file as filename to the file system.

write(stream: BinaryIO) → None

Compress and write STB file to binary stream.

PlotStyle

class ezdxf.addons.acadctb.PlotStyle
index

Table index (0-based). (int)

aci

AutoCAD Color Index (ACI) in range from 1 to 255. Has no meaning for named plot styles. (int)

description

Custom description of plot style. (str)

physical_pen_number

Specifies physical plotter pen, valid range from 1 to 32 or AUTOMATIC. (int)

virtual_pen_number

Only used by non-pen plotters and only if they are configured for virtual pens. valid range from 1 to 255 or AUTOMATIC. (int)

screen

Specifies the color intensity of the plot on the paper, valid range is from 0 to 100. (int)

If you select 100 the drawing will plotted with its full color intensity. In order for screening to work, the dithering option must be active.

linetype

Overrides the entity linetype, default value is OBJECT_LINETYPE. (bool)

adaptive_linetype

True if a complete linetype pattern is more important than a correct linetype scaling, default is True. (bool)

linepattern_size

Line pattern size, default = 0.5. (float)

lineweight

Overrides the entity lineWEIGHT, default value is OBJECT_LINEWEIGHT. This is an index into the UserStyles.lineweights table. (int)

end_style

Line end cap style, see table below, default is END_STYLE_OBJECT (int)

join_style

Line join style, see table below, default is JOIN_STYLE_OBJECT (int)

fill_style

Line fill style, see table below, default is FILL_STYLE_OBJECT (int)

dithering

Depending on the capabilities of your plotter, dithering approximates the colors with dot patterns. When this option is False, the colors are mapped to the nearest color, resulting in a smaller range of colors when plotting.

Dithering is available only whether you select the object’s color or assign a plot style color.

grayscale

Plot colors in grayscale. (bool)

Default Line Weights

# [mm]
0 0.00
1 0.05
2 0.09
3 0.10
4 0.13
5 0.15
6 0.18
7 0.20
8 0.25
9 0.30
10 0.35
11 0.40
12 0.45
13 0.50
14 0.53
15 0.60
16 0.65
17 0.70
18 0.80
19 0.90
20 1.00
21 1.06
22 1.20
23 1.40
24 1.58
25 2.00
26 2.11

Predefined Values

ezdxf.addons.acadctb.AUTOMATIC
ezdxf.addons.acadctb.OBJECT_LINEWEIGHT
ezdxf.addons.acadctb.OBJECT_LINETYPE
ezdxf.addons.acadctb.OBJECT_COLOR
ezdxf.addons.acadctb.OBJECT_COLOR2

Line End Style

../_images/ctb_line_end_style.png
END_STYLE_BUTT 0
END_STYLE_SQUARE 1
END_STYLE_ROUND 2
END_STYLE_DIAMOND 3
END_STYLE_OBJECT 4

Line Join Style

../_images/ctb_line_join_style.png
JOIN_STYLE_MITER 0
JOIN_STYLE_BEVEL 1
JOIN_STYLE_ROUND 2
JOIN_STYLE_DIAMOND 3
JOIN_STYLE_OBJECT 5

Fill Style

../_images/ctb_line_fill_style.png
FILL_STYLE_SOLID 64
FILL_STYLE_CHECKERBOARD 65
FILL_STYLE_CROSSHATCH 66
FILL_STYLE_DIAMONDS 67
FILL_STYLE_HORIZONTAL_BARS 68
FILL_STYLE_SLANT_LEFT 69
FILL_STYLE_SLANT_RIGHT 70
FILL_STYLE_SQUARE_DOTS 71
FILL_STYLE_VERICAL_BARS 72
FILL_STYLE_OBJECT 73

Linetypes

../_images/ctb_linetypes_1.png ../_images/ctb_linetypes_2.png
Linetype name Value
Solid 0
Dashed 1
Dotted 2
Dash Dot 3
Short Dash 4
Medium Dash 5
Long Dash 6
Short Dash x2 7
Medium Dash x2 8
Long Dash x2 9
Medium Lang Dash 10
Medium Dash Short Dash Short Dash 11
Long Dash Short Dash 12
Long Dash Dot Dot 13
Long Dash Dot 14
Medium Dash Dot Short Dash Dot 15
Sparse Dot 16
ISO Dash 17
ISO Dash Space 18
ISO Long Dash Dot 19
ISO Long Dash Double Dot 20
ISO Long Dash Triple Dot 21
ISO Dot 22
ISO Long Dash Short Dash 23
ISO Long Dash Double Short Dash 24
ISO Dash Dot 25
ISO Double Dash Dot 26
ISO Dash Double Dot 27
ISO Double Dash Double Dot 28
ISO Dash Triple Dot 29
ISO Double Dash Triple Dot 30
Use entity linetype 31