CadLayerFilters
from OpenCAD2D import CadLayerFilters
class CadLayerFilters(System.Object) ยท CadLayerFilters in the .NET reference
The layer filters of a drawing, read and edited as AutoCAD 2021 keeps them: property filters and group filters nested under All, the three AutoCAD makes (All Used Layers, Unreconciled New Layers, Viewport Overrides) not kept in the drawing. A filter is added, changed, renamed, deleted, made current and given layers, each one undo step; a name that is a sibling's already is refused.
Properties and fields
Dynamic
Dynamic: ClassVar[System.Collections.Generic.IReadOnlyList[System.Collections.Generic.KeyValuePair[str, str]]]
The filters AutoCAD makes, listed after those the drawing keeps; each tests one property.
Methods
AddGroup
@staticmethod
def AddGroup(
document: CadDocument,
parentPath: System.Collections.Generic.IReadOnlyList[str],
name: str,
layerNames: System.Collections.Generic.IEnumerable[str],
) -> CadEditResult
Adds a group filter, nested in a filter or at the top, holding the layers named (those the drawing has).
AddProperty
@staticmethod
def AddProperty(
document: CadDocument,
parentPath: System.Collections.Generic.IReadOnlyList[str],
name: str,
expression: str,
) -> CadEditResult
Adds a property filter, nested in a filter or at the top, with an expression of AutoCAD's form.
All
@staticmethod
def All(
filters: System.Collections.Generic.IEnumerable[CadLayerFilter],
) -> System.Collections.Generic.IEnumerable[CadLayerFilter]
The filters and every filter nested in them, depth first, in the order they are listed.
ConvertToGroup
@staticmethod
def ConvertToGroup(document: CadDocument, path: System.Collections.Generic.IReadOnlyList[str]) -> CadEditResult
Turns a property filter into a group filter of the layers it shows now, as AutoCAD's Convert to Group Filter does; the filters nested in it stay in it.
Delete
@staticmethod
def Delete(document: CadDocument, path: System.Collections.Generic.IReadOnlyList[str]) -> CadEditResult
Deletes a filter with the filters nested in it; the layers stay.
Find
@staticmethod
def Find(
filters: System.Collections.Generic.IReadOnlyList[CadLayerFilter],
path: System.Collections.Generic.IReadOnlyList[str],
) -> CadLayerFilter
Finds a filter by its names from the top, letters of either case the same.
Passes
@staticmethod
def Passes(filter: CadLayerFilter, layer: DxfLayerTableRecord, context: CadLayerFilterContext) -> bool
Whether a layer passes a filter: the layer has to pass every filter above it and the filter itself, so that a filter nested in Steel by COLOR=="1" shows the red layers of the steel ones. A property filter reads its expression, a group filter its layers.
PassesDynamic
@staticmethod
def PassesDynamic(name: str, layer: DxfLayerTableRecord, context: CadLayerFilterContext) -> bool
Whether a layer passes one of the filters AutoCAD makes, by its name: All Used Layers, Unreconciled New Layers (none, as the library does not reconcile) and Viewport Overrides.
Read
@staticmethod
def Read(database: DxfDatabase) -> System.Collections.Generic.IReadOnlyList[CadLayerFilter]
Reads the filters of the drawing: those of ACLYDICTIONARY with the filters nested in them, then those only ACAD_LAYERFILTERS keeps (marked CadLayerFilter.IsLegacy, their expression the one of the record's extended data), each level in the order of the names, letters of either case alike.
Rename
@staticmethod
def Rename(
document: CadDocument,
path: System.Collections.Generic.IReadOnlyList[str],
newName: str,
) -> CadEditResult
Renames a filter; a name a sibling has already, letters of either case the same, is refused.
SetCurrent
@staticmethod
def SetCurrent(document: CadDocument, path: System.Collections.Generic.IReadOnlyList[str]) -> CadEditResult
Marks the filter the layer list shows as the current one, as AutoCAD does when one is chosen in its tree (group 290 of its XRECORD); none marks All.
SetExpression
@staticmethod
def SetExpression(
document: CadDocument,
path: System.Collections.Generic.IReadOnlyList[str],
expression: str,
) -> CadEditResult
Changes the expression of a property filter.
SetLayers
@staticmethod
def SetLayers(
document: CadDocument,
path: System.Collections.Generic.IReadOnlyList[str],
layerNames: System.Collections.Generic.IEnumerable[str],
replace: bool,
) -> CadEditResult
Gives a group filter layers, as dragging layers onto it or Select Layers does: added to those it has, or in place of them. A layer the drawing does not have is left out.
Visible
@staticmethod
def Visible(
database: DxfDatabase,
path: System.Collections.Generic.IReadOnlyList[str],
invert: bool,
viewport: DxfViewport,
) -> System.Collections.Generic.HashSet[str]
The names of the layers a filter lists: those that pass it (those that do not where invert), the filter found by its names from the top, or by the name of one AutoCAD makes. A path that names no filter, and an empty one, is All: every layer.