CadPlotStyleSheet
from OpenCAD2D import CadPlotStyleSheet
class CadPlotStyleSheet(System.Object) ยท CadPlotStyleSheet in the .NET reference
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).
Properties and fields
ColorCount
ColorCount: ClassVar[int]
The number of styles of a colour-dependent table: one for each colour of AutoCAD's index, 1 to 255.
ColorDependentExtension
ColorDependentExtension: ClassVar[str]
The extension of a colour-dependent plot style table file: .ctb.
NamedExtension
NamedExtension: ClassVar[str]
The extension of a named plot style table file: .stb.
NormalName
NormalName: ClassVar[str]
The name of the first style of a named table, which cannot be removed or renamed.
ApplyGlobalScaleFactor
@property
def ApplyGlobalScaleFactor(self) -> bool
@ApplyGlobalScaleFactor.setter
def ApplyGlobalScaleFactor(self, value: bool) -> None
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
@property
def Description(self) -> str
@Description.setter
def Description(self, value: str | None) -> None
Gets or sets the description of the table, one line; empty for none.
FileName
@property
def FileName(self) -> str
@FileName.setter
def FileName(self, value: str | None) -> None
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. CadPlotStyleSheet.Load and the folder set it.
IsNamed
@property
def IsNamed(self) -> bool
Gets whether the table is a named one (.stb) rather than a colour-dependent one (.ctb).
LineWeights
@property
def LineWeights(self) -> System.Collections.Generic.IReadOnlyList[float]
Gets the lineweights the styles choose from, in millimetres: entry 0 is 0, "Use object lineweight".
LineWeightsInInches
@property
def LineWeightsInInches(self) -> bool
@LineWeightsInInches.setter
def LineWeightsInInches(self, value: bool) -> None
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
@property
def ScaleFactor(self) -> float
@ScaleFactor.setter
def ScaleFactor(self, value: float) -> None
Gets or sets the global scale factor of the table; 1 by default. Kept and not used.
Styles
@property
def Styles(self) -> System.Collections.Generic.IReadOnlyList[CadPlotStyle]
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
def AddStyle(self, name: str) -> CadPlotStyle
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
@staticmethod
def CheckStyleName(name: str) -> str
Says why a name cannot name a plot style, as AutoCAD refuses one: empty, longer than 255 letters, or with a < > / \ " : ; ? * | , = ` in it.
Clone
def Clone(self) -> CadPlotStyleSheet
Makes a copy that changes apart from this one.
FromText
@staticmethod
def FromText(text: str, isNamed: bool) -> CadPlotStyleSheet
Reads a table from its text, as CadPlotStyleSheet.ToText gives it and AutoCAD's files hold it.
LineWeightIndexOf
def LineWeightIndexOf(self, millimetres: float) -> int
Gets the entry of CadPlotStyleSheet.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
def LineWeightOf(self, style: CadPlotStyle) -> float
Gets the millimetres a style plots at: its entry of CadPlotStyleSheet.LineWeights; 0 for "Use object lineweight" or an entry the table lacks.
Load
@staticmethod
def Load(path: str) -> CadPlotStyleSheet
Reads a .ctb or .stb file.
NewColorDependent
@staticmethod
def NewColorDependent() -> CadPlotStyleSheet
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
@staticmethod
def NewNamed() -> CadPlotStyleSheet
Makes a named table of one style, Normal, which changes nothing; CadPlotStyleSheet.AddStyle adds the others.
Read
@staticmethod
def Read(bytes: Sequence[int] | System.Array[int]) -> CadPlotStyleSheet
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
def RemoveStyle(self, name: str) -> bool
Takes a style out of a named table, as Delete Style of the editor does.
RenameStyle
def RenameStyle(self, name: str, newName: str) -> None
Gives a style of a named table another name, as editing its name in the editor does.
Save
def Save(self, path: str) -> None
Writes the table to a .ctb or .stb file (CadPlotStyleSheet.ToBytes), the folder made where it is missing, and sets CadPlotStyleSheet.FileName to the file's name.
SetLineWeight
def SetLineWeight(self, index: int, millimetres: float) -> None
Changes an entry of CadPlotStyleSheet.LineWeights, as Edit Lineweights of the editor does; entry 0 stays "Use object lineweight".
StyleForColorIndex
def StyleForColorIndex(self, colorIndex: int) -> CadPlotStyle
Gets the style of a colour of AutoCAD's index in a colour-dependent table.
StyleNamed
def StyleNamed(self, name: str) -> CadPlotStyle
Gets the style of a name in a named table, letters of either case the same.
ToBytes
def ToBytes(self) -> System.Array[int]
Gives the file: the head, the three numbers and the packed CadPlotStyleSheet.ToText, as CadPlotStyleSheet.Save writes it.
ToString
def ToString(self) -> str
ToText
def ToText(self) -> str
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.