Selector Methods
CadQuery selector strings allow filtering various types of object lists.
Most commonly, Edges, Faces, and Vertices are used, but all objects types can be filtered.
Selector Classes
Class |
Description |
NearestToPointSelector(pnt) |
Selects object nearest the provided point. |
ParallelDirSelector(vector[tolerance]) |
Selects objects parallel with the provided direction. |
DirectionSelector(vector[tolerance]) |
Selects objects aligned with the provided direction. |
PerpendicularDirSelector(vector[tolerance]) |
Selects objects perpendicular with the provided direction. |
TypeSelector(typeString) |
Selects objects of the prescribed topological type. |
DirectionMinMaxSelector(vector[directionMax]) |
Selects objects closest or farthest in the specified direction. |
StringSyntaxSelector(selectorString) |
Filter lists objects using a simple string syntax. |
Selector String Modifiers
Selectors are a complex topic: see
CadQuery String Selectors for more information.
Axis Strings are: X, Y, Z, XY, YZ, XZ
Examples of Filtering Faces
All types of filters work on faces. In most cases, the selector refers to the direction of the normal vector of the face.
If a face is not planar, selectors are evaluated at the center of mass of the face. This can lead to results that are quite unexpected.
Selector |
Selector Class |
Selects |
# Objects Returned |
+Z |
DirectionSelector |
Faces with normal in +z direction |
0 or 1 |
|Z |
ParallelDirSelector |
Faces parallel to xy plane |
0..many |
-X |
DirectionSelector |
Faces with normal in neg x direction |
0..many |
#Z |
PerpendicularDirSelector |
Faces perpendicular to z direction |
0..many |
%Plane |
TypeSelector |
Faces of type plane |
0..many |
>Y |
DirectionMinMaxSelector |
Face farthest in the positive y dir |
0 or 1 |
<Y |
DirectionMinMaxSelector |
Face farthest in the negative y dir |
0 or 1 |
Examples of Filtering Edges
Some filter types are not supported for edges. The selector usually refers to the direction of the edge.
Non-linear edges are not selected for any selectors except type (%). Non-linear edges are never returned when these filters are applied.
Selector |
Selector Class |
Selects |
# Objects Returned |
+Z |
DirectionSelector |
Edges aligned in the Z direction |
0..many |
|Z |
ParallelDirSelector |
Edges parallel to z direction |
0..many |
-X |
DirectionSelector |
Edges aligned in neg x direction |
0..many |
#Z |
PerpendicularDirSelector |
Edges perpendicular to z direction |
0..many |
%Plane |
TypeSelector |
Edges type line |
0..many |
>Y |
DirectionMinMaxSelector |
Edges farthest in the positive y dir |
0 or 1 |
<Y |
DirectionMinMaxSelector |
Edges farthest in the negative y dir |
0 or 1 |
Examples of Filtering Vertices
Only a few of the filter types apply to vertices. The location of the vertex is the subject of the filter.
Selector |
Selector Class |
Selects |
# Objects Returned |
>Y |
DirectionMinMaxSelector |
Vertices farthest in the positive y dir |
0 or 1 |
<Y |
DirectionMinMaxSelector |
Vertices farthest in the negative y dir |
0 or 1 |