Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

fixed NearestToPointSelector failure with tuple as arguments #93

Merged
merged 1 commit into from
Jun 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadquery/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self,pnt ):
def filter(self,objectList):

def dist(tShape):
return tShape.Center().sub(self.pnt).Length
return tShape.Center().sub(Vector(*self.pnt)).Length
#if tShape.ShapeType == 'Vertex':
# return tShape.Point.sub(toVector(self.pnt)).Length
#else:
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCQSelectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ def testNearestTo(self):
c = CQ(makeUnitCube())

#nearest vertex to origin is (0,0,0)
t = Vector(0.1,0.1,0.1)
t = (0.1,0.1,0.1)

v = c.vertices(selectors.NearestToPointSelector(t)).vals()[0]
self.assertTupleAlmostEquals((0.0,0.0,0.0),(v.X,v.Y,v.Z),3)

t = Vector(0.1,0.1,0.2)
t = (0.1,0.1,0.2)
#nearest edge is the vertical side edge, 0,0,0 -> 0,0,1
e = c.edges(selectors.NearestToPointSelector(t)).vals()[0]
v = c.edges(selectors.NearestToPointSelector(t)).vertices().vals()
Expand Down