MCPcopy
hub / github.com/CadQuery/cadquery / StringSyntaxSelector

Class StringSyntaxSelector

cadquery/selectors.py:825–888  ·  view source on GitHub ↗

r""" Filter lists objects using a simple string syntax. All of the filters available in the string syntax are also available ( usually with more functionality ) through the creation of full-fledged selector objects. see :py:class:`Selector` and its subclasses Filtering works differe

Source from the content-addressed store, hash-verified

823
824
825class StringSyntaxSelector(Selector):
826 r"""
827 Filter lists objects using a simple string syntax. All of the filters available in the string syntax
828 are also available ( usually with more functionality ) through the creation of full-fledged
829 selector objects. see :py:class:`Selector` and its subclasses
830
831 Filtering works differently depending on the type of object list being filtered.
832
833 :param selectorString: A two-part selector string, [selector][axis]
834
835 :return: objects that match the specified selector
836
837 ***Modifiers*** are ``('|','+','-','<','>','%')``
838
839 :\|:
840 parallel to ( same as :py:class:`ParallelDirSelector` ). Can return multiple objects.
841 :#:
842 perpendicular to (same as :py:class:`PerpendicularDirSelector` )
843 :+:
844 positive direction (same as :py:class:`DirectionSelector` )
845 :-:
846 negative direction (same as :py:class:`DirectionSelector` )
847 :>:
848 maximize (same as :py:class:`DirectionMinMaxSelector` with directionMax=True)
849 :<:
850 minimize (same as :py:class:`DirectionMinMaxSelector` with directionMax=False )
851 :%:
852 curve/surface type (same as :py:class:`TypeSelector`)
853
854 ***axisStrings*** are: ``X,Y,Z,XY,YZ,XZ`` or ``(x,y,z)`` which defines an arbitrary direction
855
856 It is possible to combine simple selectors together using logical operations.
857 The following operations are supported
858
859 :and:
860 Logical AND, e.g. >X and >Y
861 :or:
862 Logical OR, e.g. \|X or \|Y
863 :not:
864 Logical NOT, e.g. not #XY
865 :exc(ept):
866 Set difference (equivalent to AND NOT): \|X exc >Z
867
868 Finally, it is also possible to use even more complex expressions with nesting
869 and arbitrary number of terms, e.g.
870
871 (not >X[0] and #XY) or >XY[0]
872
873 Selectors are a complex topic: see :ref:`selector_reference` for more information
874 """
875
876 def __init__(self, selectorString):
877 """
878 Feed the input string through the parser and construct an relevant complex selector object
879 """
880 self.selectorString = selectorString
881 parse_result = _expression_grammar.parse_string(selectorString, parse_all=True)
882 self.mySelector = parse_result.asList()[0]

Callers 4

_selectMethod · 0.85
_filterMethod · 0.85
_filterMethod · 0.85
_filter_singleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected