CadLayerExpression
from OpenCAD2D import CadLayerExpression
class CadLayerExpression(System.Object) ยท CadLayerExpression in the .NET reference
The expression of a property filter, as AutoCAD's FilterExpression keeps it (group 301 of the filter's XRECORD): rules of the form NAME=="A*" joined by AND and OR, AND binding tighter, with brackets; read as a list of alternatives (OR), each a list of rules all of which a layer has to pass (AND). NAME=="1_Arch*" AND OFF=="False" is one alternative of two rules; NAME=="*dim" OR NAME=="*text" is two of one.
Constructors
__init__
def __init__(
self,
alternatives: System.Collections.Generic.IReadOnlyList[System.Collections.Generic.IReadOnlyList[CadLayerRule]],
) -> None
Makes an expression of alternatives.
Properties and fields
Alternatives
@property
def Alternatives(
self,
) -> System.Collections.Generic.IReadOnlyList[System.Collections.Generic.IReadOnlyList[CadLayerRule]]
Gets the alternatives: a layer passes when it passes all the rules of one of them; none passes every layer.
Variables
Variables: ClassVar[System.Collections.Generic.IReadOnlyList[str]]
Gets the properties a filter can test, in the order of AutoCAD's columns.
Methods
Matches
def Matches(self, layer: DxfLayerTableRecord, context: CadLayerFilterContext) -> bool
Whether a layer passes: one alternative whose rules it passes all. Where the expression has no rule every layer passes; a rule of a property the library does not know passes none, as AutoCAD answers one.
ToString
def ToString(self) -> str
Gives the expression as AutoCAD's filter dialog writes it: rules joined by AND, alternatives by OR, no brackets.
TryParse
@staticmethod
def TryParse(text: str) -> tuple[bool, CadLayerExpression]
Reads an expression: NAME=="A*" AND COLOR=="1", OFF == "FALSE" and FROZEN == "FALSE", ( NAME== "A*" ), letters of either case, spaces round the signs or none.