Updated CadQuery library.

This commit is contained in:
Jeremy Wright 2015-06-21 21:47:29 -04:00
parent 880f80b1e6
commit b9cd7404b8
4 changed files with 943 additions and 914 deletions

File diff suppressed because it is too large Load Diff

View File

@ -249,6 +249,7 @@ def getPaths(freeCadSVG):
else:
return ([],[])
def getSVG(shape,opts=None):
"""
Export a shape to SVG

View File

@ -616,7 +616,7 @@ class Solid(Shape):
# needs to allow free-space wires ( those not made from a workplane )
@classmethod
def makeLoft(cls, listOfWire):
def makeLoft(cls, listOfWire, ruled=False):
"""
makes a loft from a list of wires
The wires will be converted into faces when possible-- it is presumed that nobody ever actually
@ -624,7 +624,7 @@ class Solid(Shape):
"""
# the True flag requests building a solid instead of a shell.
return Shape.cast(FreeCADPart.makeLoft([i.wrapped for i in listOfWire], True))
return Shape.cast(FreeCADPart.makeLoft([i.wrapped for i in listOfWire], True, ruled))
@classmethod
def makeWedge(cls, xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max, pnt=None, dir=None):

View File

@ -62,7 +62,7 @@ class NearestToPointSelector(Selector):
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:
@ -70,6 +70,49 @@ class NearestToPointSelector(Selector):
return [ min(objectList,key=dist) ]
class BoxSelector(Selector):
"""
Selects objects inside the 3D box defined by 2 points.
If `boundingbox` is True only the objects that have their bounding
box inside the given box is selected. Otherwise only center point
of the object is tested.
Applicability: all types of shapes
Example::
CQ(aCube).edges(BoxSelector((0,1,0), (1,2,1))
"""
def __init__(self, point0, point1, boundingbox=False):
self.p0 = Vector(*point0)
self.p1 = Vector(*point1)
self.test_boundingbox = boundingbox
def filter(self, objectList):
result = []
x0, y0, z0 = self.p0.toTuple()
x1, y1, z1 = self.p1.toTuple()
def isInsideBox(p):
# using XOR for checking if x/y/z is in between regardless
# of order of x/y/z0 and x/y/z1
return ((p.x < x0) ^ (p.x < x1)) and \
((p.y < y0) ^ (p.y < y1)) and \
((p.z < z0) ^ (p.z < z1))
for o in objectList:
if self.test_boundingbox:
bb = o.BoundingBox()
if isInsideBox(Vector(bb.xmin, bb.ymin, bb.zmin)) and \
isInsideBox(Vector(bb.xmax, bb.ymax, bb.zmax)):
result.append(o)
else:
if isInsideBox(o.Center()):
result.append(o)
return result
class BaseDirSelector(Selector):
"""