Skip to content

Commit d23df7d

Browse files
Aditional selectors
1 parent 0ef98e3 commit d23df7d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cadquery/selectors.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ def dist(tShape):
8686
return [min(objectList, key=dist)]
8787

8888

89+
class NearestToShapeSelector(Selector):
90+
"""
91+
Selects object nearest the provided Shape.
92+
93+
Applicability: All Types of Shapes
94+
95+
"""
96+
97+
def __init__(self, s: Shape):
98+
self.shape = s
99+
100+
def filter(self, objectList: Sequence[Shape]):
101+
102+
return [min(objectList, key=lambda el: self.s.distance(el))]
103+
104+
89105
class BoxSelector(Selector):
90106
"""
91107
Selects objects inside the 3D box defined by 2 points.
@@ -870,3 +886,11 @@ def filter(self, objectList: Sequence[Shape]):
870886
Filter give object list through th already constructed complex selector object
871887
"""
872888
return self.mySelector.filter(objectList)
889+
890+
891+
#%% Aliases
892+
893+
NearestToPoint = NearestToPointSelector
894+
NearestToShape = NearestToShapeSelector
895+
Parallel = ParallelDirSelector
896+
Perpendicular = PerpendicularDirSelector

0 commit comments

Comments
 (0)