CadLayerEditor
from OpenCAD2D import CadLayerEditor
class CadLayerEditor(System.Object) ยท CadLayerEditor in the .NET reference
The edits of the layer table, as the layer box, the Layer manager and the LAYER command make them: each one undo step through CadDocument.ApplyEdit, refused as AutoCAD refuses it where AutoCAD would not do it.
Methods
Add
@staticmethod
def Add(document: CadDocument, name: str) -> CadEditResult
Adds a layer of the colour White (7) and the linetype Continuous, as AutoCAD's New layer.
Delete
@staticmethod
def Delete(document: CadDocument, name: str) -> CadEditResult
Deletes a layer, as the Layer manager deletes one: only a layer nothing uses. Refused, with the reason, for layer 0, Defpoints, the current layer, a layer of an external reference (Base|Steel), a layer an entity is on, in any space or block. A layer a viewport of a layout freezes is deleted, the viewports thawed in the same undo step, which one undo takes back with the layer.
DeleteWithObjects
@staticmethod
def DeleteWithObjects(
document: CadDocument,
names: System.Collections.Generic.IReadOnlyCollection[str],
) -> CadEditResult
Deletes layers with everything on them, as AutoCAD's LAYDEL does: every object on the layers, in model space, in the layouts and in every block (the blocks' definitions too), and the attributes of the block references, is erased, then the layers. A drawing with 12 lines on layer TMP and a block whose definition holds 4 more has none of the 16 after TMP is deleted. One undo step.
IsLocked
@staticmethod
def IsLocked(database: DxfDatabase, name: str) -> bool
Gets whether a layer of the drawing is locked; false for a layer it has not.
Merge
@staticmethod
def Merge(
document: CadDocument,
names: System.Collections.Generic.IReadOnlyCollection[str],
target: str,
) -> CadEditResult
Merges layers into another, as AutoCAD's LAYMRG does: every object on the layers merged, in model space, in the layouts, in every block (those of the blocks' definitions too) and the attributes of the block references, is put on the target layer, and the layers merged are deleted. A drawing with a line on layer WALL and another on layer DOOR, DOOR merged into WALL, has both lines on WALL afterwards and no layer DOOR. One undo step.
Rename
@staticmethod
def Rename(document: CadDocument, name: str, newName: str) -> CadEditResult
Renames a layer with every object on it, as the Layer manager's name cell and AutoCAD 2021's -RENAME do: the new name with the spaces around it taken off, so that " T2 " names it T2, and letters of another case taken (TEXT to text). Refused in AutoCAD 2021's words: layer 0, Cannot rename layer "0".; a name already used, letters of either case the same, A layer named "DIM" already exists.; an empty name, one with a character a layer name cannot hold (< > / \ " : ; ? * | , = `) and a layer of an external reference, Invalid layer name. Defpoints is renamed, as AutoCAD renames it.
SetColor
@staticmethod
def SetColor(document: CadDocument, name: str, color: DxfColor) -> CadEditResult
Gives a layer a colour as AutoCAD's Select Color dialog does: one of the index, written to group 62 (below nought while the layer is off), or a true colour, written to group 420 with the index nearest it in 62, so that red, green and blue 10, 20, 30 is written 420 = 660510 beside the nearest index. ByLayer and ByBlock are refused, as a layer cannot take them, and a true colour in a file older than AutoCAD 2004 (AC1018), which has none.
@staticmethod
def SetColor(document: CadDocument, name: str, colorIndex: int) -> CadEditResult
Gives a layer a colour of AutoCAD's index, 1 to 255; a true colour it had is taken out, as AutoCAD's index colour does.
SetCurrent
@staticmethod
def SetCurrent(document: CadDocument, name: str) -> CadEditResult
Makes a layer current, as the layer box does; a frozen layer is refused, as AutoCAD refuses it, and a layer of an external reference (grid|WALL) in the words AutoCAD 2021 refuses CLAYER set to one.
SetDescription
@staticmethod
def SetDescription(document: CadDocument, name: str, description: str) -> CadEditResult
Gives a layer a description, as -LAYER Description does; one of an external reference marked 1024, as AutoCAD 2021 marks it.
SetFrozen
@staticmethod
def SetFrozen(document: CadDocument, name: str, frozen: bool) -> CadEditResult
Freezes or thaws a layer; the current layer is not frozen, as AutoCAD refuses it.
SetLineWeight
@staticmethod
def SetLineWeight(document: CadDocument, name: str, lineWeight: DxfLineWeight) -> CadEditResult
Gives a layer a lineweight: Default, or one of AutoCAD's widths; ByLayer and ByBlock are refused, as a layer cannot take them.
SetLinetype
@staticmethod
def SetLinetype(document: CadDocument, name: str, linetype: str) -> CadEditResult
Gives a layer a linetype the drawing has, as the Layer manager does; one it has not is refused, as the library keeps no standard linetypes of its own to load one from (AutoCAD's acad.lin is Autodesk's and is not shipped).
SetLocked
@staticmethod
def SetLocked(document: CadDocument, name: str, locked: bool) -> CadEditResult
Locks or unlocks a layer: the objects on a locked layer are drawn but not changed.
SetOn
@staticmethod
def SetOn(document: CadDocument, name: str, on: bool) -> CadEditResult
Switches a layer on or off; the current layer may be switched off, as in AutoCAD.
SetPlotStyle
@staticmethod
def SetPlotStyle(document: CadDocument, name: str, plotStyle: str) -> CadEditResult
Gives a layer a plot style of the drawing's plot style names, as -LAYER PStyle and the Plot Style column do. Refused in a drawing plotted by colour, where AutoCAD names the plot style of a layer by its colour (Color_30) and takes no other, and for a name the drawing has not.
SetPlottable
@staticmethod
def SetPlottable(document: CadDocument, name: str, plotted: bool) -> CadEditResult
Sets whether a layer is plotted, as -LAYER Plot does; one of an external reference marked 8, as AutoCAD 2021 marks it.
SetTransparency
@staticmethod
def SetTransparency(document: CadDocument, name: str, percent: int) -> CadEditResult
Gives a layer a transparency of 0 to 90 per cent, as -LAYER TRansparency does: 50 is written as the alpha 127, as AutoCAD keeps it, and 0 as solid; one of an external reference marked 128, as AutoCAD 2021 marks it.
Translate
@staticmethod
def Translate(
document: CadDocument,
mappings: System.Collections.Generic.IReadOnlyList[CadLayerMapping],
settings: CadLayerTranslatorSettings,
log: System.Collections.Generic.IList[str],
) -> CadEditResult
Translates layers, as AutoCAD's Layer Translator does for the mappings made: the layers translated to are made where the drawing has none (with the linetype copied from the standards file where the drawing has none) and given the colour, linetype, lineweight, transparency and plot style of the mapping where it has them; every object of a layer translated, in model space, the layouts and the blocks (those of the blocks left out where the settings say so), the attributes of block references among them, is put on the layer it is translated to; the layers translated from are deleted but for layer 0, Defpoints and any layer another mapping translates to. A drawing with 40 lines on OLD-WALL and a mapping of OLD-WALL to WALL (colour 3) has the 40 lines on WALL, WALL green, and no layer OLD-WALL afterwards. One undo step.