Table of Contents

Class CadPlotStyleSheet

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

A plot style table, the content of AutoCAD's .ctb (colour-dependent: 255 styles, one for each colour of AutoCAD's index) or .stb (named: styles a drawing's objects and layers are given by name, the first of them Normal) file, with the reader and writer of the file. A plot looks an object's style up in it (CadPlotStyleResolver).

public sealed class CadPlotStyleSheet
Inheritance
CadPlotStyleSheet
Inherited Members

Remarks

The file is a text of nested blocks (plot_style{ 0{ name="Color_1 … } }, the lineweight list custom_lineweight_table{ 0=0.000000 … }), packed as AutoCAD packs its PIA files: the head PIAFILEVERSION_2.0,CTBVER1,compress (STBVER1 for a named table), a line break and pmzlibcodec, three whole numbers of four bytes (the Adler-32 of the packed stream, the length of the text, the length of the stream), and the text as a zlib stream. A table read and written again gives the same text, byte for byte (ToText()), and the same file where the same runtime deflates it (ToBytes()); the deflated bytes of one table differ from AutoCAD's and from another runtime's, which every reader inflates alike.

A table's lineweight list holds the millimetres a style's LineWeightIndex chooses from, 27 entries as AutoCAD starts it (0, 0.05, 0.09 … 2.11); entry 0 is "Use object lineweight".

Fields

ColorCount

The number of styles of a colour-dependent table: one for each colour of AutoCAD's index, 1 to 255.

ColorDependentExtension

The extension of a colour-dependent plot style table file: .ctb.

NamedExtension

The extension of a named plot style table file: .stb.

NormalName

The name of the first style of a named table, which cannot be removed or renamed.

Properties

ApplyGlobalScaleFactor

Gets or sets whether the global scale factor is applied to the linetypes that are not ISO's (the editor's Apply global scale factor to non-ISO linetypes); off by default. Kept and not used.

Description

Gets or sets the description of the table, one line; empty for none.

FileName

Gets or sets the name of the file the table is kept in, as monochrome.ctb, which a drawing's plot settings name it by; empty for a table not yet saved. Load(string) and the folder set it.

IsNamed

Gets whether the table is a named one (.stb) rather than a colour-dependent one (.ctb).

LineWeights

Gets the lineweights the styles choose from, in millimetres: entry 0 is 0, "Use object lineweight".

LineWeightsInInches

Gets or sets whether the editor lists lineweights in inches (custom_lineweight_display_units 1) rather than millimetres (0): the table's lineweights are millimetres either way.

ScaleFactor

Gets or sets the global scale factor of the table; 1 by default. Kept and not used.

Styles

Gets the styles: for a colour-dependent table the 255 of colours 1 to 255 in that order, for a named one Normal and then the others in the order they were added.

Methods

AddStyle(string)

Adds a style to a named table, as Add Style of the editor does: one that changes nothing, its colour kind a named table's, last in the list.

CheckStyleName(string)

Says why a name cannot name a plot style, as AutoCAD refuses one: empty, longer than 255 letters, or with a < > / \ " : ; ? * | , = ` in it.

Clone()

Makes a copy that changes apart from this one.

FromText(string, bool)

Reads a table from its text, as ToText() gives it and AutoCAD's files hold it.

LineWeightIndexOf(double)

Gets the entry of LineWeights that holds a lineweight, to the hundredth of a millimetre; the table gets a new entry at its end where it has none, as Edit Lineweights adds one.

LineWeightOf(CadPlotStyle)

Gets the millimetres a style plots at: its entry of LineWeights; 0 for "Use object lineweight" or an entry the table lacks.

Load(string)

Reads a .ctb or .stb file.

NewColorDependent()

Makes a colour-dependent table of 255 styles that change nothing, Color_1 to Color_255: a plot with it is as with no table, as AutoCAD's acad.ctb.

NewNamed()

Makes a named table of one style, Normal, which changes nothing; AddStyle(string) adds the others.

Read(byte[])

Reads a table from the bytes of a file. The head tells a colour-dependent table (CTBVER1) from a named one (STBVER1); the numbers after it are not checked, the stream is inflated to its end. A block or a line the reader does not know is passed over, a value that does not read keeps its default, a pen or a screening out of its range is brought to the range, and a colour-dependent table that lists fewer than 255 styles keeps the default of the others.

RemoveStyle(string)

Takes a style out of a named table, as Delete Style of the editor does.

RenameStyle(string, string)

Gives a style of a named table another name, as editing its name in the editor does.

Save(string)

Writes the table to a .ctb or .stb file (ToBytes()), the folder made where it is missing, and sets FileName to the file's name.

SetLineWeight(int, double)

Changes an entry of LineWeights, as Edit Lineweights of the editor does; entry 0 stays "Use object lineweight".

StyleForColorIndex(int)

Gets the style of a colour of AutoCAD's index in a colour-dependent table.

StyleNamed(string)

Gets the style of a name in a named table, letters of either case the same.

ToBytes()

Gives the file: the head, the three numbers and the packed ToText(), as Save(string) writes it.

ToString()
ToText()

Gives the text of the file, before it is packed: lines ended by a line feed, blocks indented by a space a level, numbers with six decimals, the text ended as the file ends it, by a nought byte. A colour-dependent table lists the colours (aci_table) and says aci_table_available=TRUE.