Class CadLayerEditor
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
The edits of the layer table, as the layer box, the Layer manager and the LAYER command make them: each one undo step through ApplyEdit(string, IReadOnlyList<CadEditRecord>, Action<CadEditScope>), refused as AutoCAD refuses it where AutoCAD would not do it.
public static class CadLayerEditor
- Inheritance
-
CadLayerEditor
- Inherited Members
Methods
- Add(CadDocument, string)
Adds a layer of the colour White (7) and the linetype Continuous, as AutoCAD's New layer.
- Delete(CadDocument, string)
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(CadDocument, IReadOnlyCollection<string>)
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(DxfDatabase, string)
Gets whether a layer of the drawing is locked; false for a layer it has not.
- Merge(CadDocument, IReadOnlyCollection<string>, string)
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(CadDocument, string, string)
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(CadDocument, string, DxfColor)
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.
- SetColor(CadDocument, string, int)
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(CadDocument, string)
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(CadDocument, string, string)
Gives a layer a description, as -LAYER Description does; one of an external reference marked 1024, as AutoCAD 2021 marks it.
- SetFrozen(CadDocument, string, bool)
Freezes or thaws a layer; the current layer is not frozen, as AutoCAD refuses it.
- SetLineWeight(CadDocument, string, DxfLineWeight)
Gives a layer a lineweight: Default, or one of AutoCAD's widths; ByLayer and ByBlock are refused, as a layer cannot take them.
- SetLinetype(CadDocument, string, string)
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(CadDocument, string, bool)
Locks or unlocks a layer: the objects on a locked layer are drawn but not changed.
- SetOn(CadDocument, string, bool)
Switches a layer on or off; the current layer may be switched off, as in AutoCAD.
- SetPlotStyle(CadDocument, string, string)
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(CadDocument, string, bool)
Sets whether a layer is plotted, as -LAYER Plot does; one of an external reference marked 8, as AutoCAD 2021 marks it.
- SetTransparency(CadDocument, string, int)
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(CadDocument, IReadOnlyList<CadLayerMapping>, CadLayerTranslatorSettings, IList<string>)
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.