Updated the CadQuery library.

This commit is contained in:
Jeremy Mack Wright 2015-09-17 10:32:02 -04:00
parent 0c89c85d4a
commit b491645783
2 changed files with 12 additions and 4 deletions

View File

@ -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):

View File

@ -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):
"""