From b491645783e1d8186fabad7367b1cbba61d1445b Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Thu, 17 Sep 2015 10:32:02 -0400 Subject: [PATCH] Updated the CadQuery library. --- CadQuery/Libs/cadquery/CQ.py | 4 ++++ CadQuery/Libs/cadquery/selectors.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CadQuery/Libs/cadquery/CQ.py b/CadQuery/Libs/cadquery/CQ.py index 7504b16..cc03f8b 100644 --- a/CadQuery/Libs/cadquery/CQ.py +++ b/CadQuery/Libs/cadquery/CQ.py @@ -298,6 +298,10 @@ class CQ(object): For now you can work around by creating a workplane and then offsetting the center afterwards. """ + if len(self.objects) > 1: + raise ValueError("Workplane cannot be created if more than" + " 1 object is selected.") + obj = self.objects[0] def _computeXdir(normal): diff --git a/CadQuery/Libs/cadquery/selectors.py b/CadQuery/Libs/cadquery/selectors.py index ada9bd5..be07d7b 100644 --- a/CadQuery/Libs/cadquery/selectors.py +++ b/CadQuery/Libs/cadquery/selectors.py @@ -291,13 +291,13 @@ class DirectionMinMaxSelector(Selector): allow '>(0,0,1)' to work. """ - def __init__(self,vector,directionMax=True): + def __init__(self, vector, directionMax=True, tolerance=0.0001): self.vector = vector self.max = max self.directionMax = directionMax + self.TOLERANCE = tolerance def filter(self,objectList): - #then sort by distance from origin, along direction specified def distance(tShape): return tShape.Center().dot(self.vector) #if tShape.ShapeType == 'Vertex': @@ -306,10 +306,14 @@ class DirectionMinMaxSelector(Selector): # pnt = tShape.Center() #return pnt.dot(self.vector) + # find out the max/min distance if self.directionMax: - return [ max(objectList,key=distance) ] + d = max(map(distance, objectList)) else: - return [ min(objectList,key=distance) ] + d = min(map(distance, objectList)) + + # return all objects at the max/min distance (within a tolerance) + return filter(lambda o: abs(d - distance(o)) < self.TOLERANCE, objectList) class BinarySelector(Selector): """