diff --git a/CadQuery/Libs/cadquery/CQ.py b/CadQuery/Libs/cadquery/CQ.py
index d666659..708f6de 100644
--- a/CadQuery/Libs/cadquery/CQ.py
+++ b/CadQuery/Libs/cadquery/CQ.py
@@ -795,6 +795,44 @@ class CQ(object):
solid.wrapped = s.wrapped
return self.newObject([s])
+ def chamfer(self, length, length2 = None):
+ """
+ Chamfers a solid on the selected edges.
+
+ The edges on the stack are chamfered. The solid to which the
+ edges belong must be in the parent chain of the selected
+ edges.
+
+ Optional parameter `length2` can be supplied with a different
+ value than `length` for a chamfer that is shorter on one side
+ longer on the other side.
+
+ :param length: the length of the fillet, must be greater than zero
+ :param length2: optional parameter for asymmetrical chamfer
+ :type length: positive float
+ :type length2: positive float
+ :raises: ValueError if at least one edge is not selected
+ :raises: ValueError if the solid containing the edge is not in the chain
+ :returns: cq object with the resulting solid selected.
+
+ This example will create a unit cube, with the top edges chamfered::
+
+ s = Workplane("XY").box(1,1,1).faces("+Z").chamfer(0.1)
+
+ This example will create chamfers longer on the sides::
+
+ s = Workplane("XY").box(1,1,1).faces("+Z").chamfer(0.2, 0.1)
+ """
+ solid = self.findSolid()
+
+ edgeList = self.edges().vals()
+ if len(edgeList) < 1:
+ raise ValueError("Chamfer requires that edges be selected")
+
+ s = solid.chamfer(length, length2, edgeList)
+
+ solid.wrapped = s.wrapped
+ return self.newObject([s])
class Workplane(CQ):
"""
@@ -2299,11 +2337,11 @@ class Workplane(CQ):
(xp, yp, zp) = pnt.toTuple()
if centered[0]:
- xp -= radius
+ xp -= radius * direct.x
if centered[1]:
- yp -= radius
+ yp -= radius * direct.y
if centered[2]:
- zp -= radius
+ zp -= radius * direct.z
return Solid.makeSphere(radius, Vector(xp, yp, zp), direct, angle1, angle2, angle3)
diff --git a/CadQuery/Libs/cadquery/cheatsheet/cadquery_cheatsheet.html b/CadQuery/Libs/cadquery/cheatsheet/cadquery_cheatsheet.html
new file mode 100644
index 0000000..bb58252
--- /dev/null
+++ b/CadQuery/Libs/cadquery/cheatsheet/cadquery_cheatsheet.html
@@ -0,0 +1,404 @@
+
+
+
+ CadQuery Cheatsheet
+
+
+
+
+
+
+
+
+
BREP Terminology
+
+
+ vertex |
+ A single point in space |
+
+
+ edge |
+ A connection between two or more vertices along a particular path (called a curve) |
+
+
+ wire |
+ A collection of edges that are connected together |
+
+
+ face |
+ A set of edges or wires that enclose a surface |
+
+
+ shell |
+ A collection of faces that are connected together along some of their edges |
+
+
+ solid |
+ A shell that has a closed interior |
+
+
+ compound |
+ A collection of solids |
+
+
+
+
+
Named Planes
+ Available named planes are as follows. Direction references refer to the global directions.
+
+
+ Name |
+ xDir |
+ yDir |
+ zDir |
+
+
+ XY |
+ +x |
+ +y |
+ +z |
+
+
+ YZ |
+ +y |
+ +z |
+ +x |
+
+
+ XZ |
+ +x |
+ +z |
+ -y |
+
+
+ front |
+ +x |
+ +y |
+ +z |
+
+
+ back |
+ -x |
+ +y |
+ -z |
+
+
+ left |
+ +z |
+ +y |
+ -x |
+
+
+ right |
+ -z |
+ +y |
+ +x |
+
+
+ top |
+ +x |
+ -z |
+ +y |
+
+
+ bottom |
+ +x |
+ +z |
+ -y |
+
+
+
+
+
Core Classes
+
+
+ Class |
+ Description |
+
+
+ CQ(obj) |
+ Provides enhanced functionality for a wrapped CAD primitive. |
+
+
+ Plane(origin, xDir, normal) |
+ A 2d coordinate system in space, with the x-y axes on the a plane, and a particular point as the origin. |
+
+
+ Workplane(inPlane[origin, obj]) |
+ Defines a coordinate system in space, in which 2-d coordinates can be used. |
+
+
+
+
+
+
+
Selector Methods
+ CadQuery selector strings allow filtering various types of object lists.
+ Most commonly, Edges, Faces, and Vertices are used, but all objects types can be filtered.
+
+
+
+
Selector Classes
+
+
+ Class |
+ Description |
+
+
+ NearestToPointSelector(pnt) |
+ Selects object nearest the provided point. |
+
+
+ ParallelDirSelector(vector[tolerance]) |
+ Selects objects parallel with the provided direction. |
+
+
+ DirectionSelector(vector[tolerance]) |
+ Selects objects aligned with the provided direction. |
+
+
+ PerpendicularDirSelector(vector[tolerance]) |
+ Selects objects perpendicular with the provided direction. |
+
+
+ TypeSelector(typeString) |
+ Selects objects of the prescribed topological type. |
+
+
+ DirectionMinMaxSelector(vector[directionMax]) |
+ Selects objects closest or farthest in the specified direction. |
+
+
+ StringSyntaxSelector(selectorString) |
+ Filter lists objects using a simple string syntax. |
+
+
+
+
+
Selector String Modifiers
+ Selectors are a complex topic: see
CadQuery String Selectors for more information.
+ Axis Strings are: X, Y, Z, XY, YZ, XZ
+
+
+
+
Examples of Filtering Faces
+ All types of filters work on faces. In most cases, the selector refers to the direction of the normal vector of the face.
+ If a face is not planar, selectors are evaluated at the center of mass of the face. This can lead to results that are quite unexpected.
+
+
+ Selector |
+ Selector Class |
+ Selects |
+ # Objects Returned |
+
+
+ +Z |
+ DirectionSelector |
+ Faces with normal in +z direction |
+ 0 or 1 |
+
+
+ |Z |
+ ParallelDirSelector |
+ Faces parallel to xy plane |
+ 0..many |
+
+
+ -X |
+ DirectionSelector |
+ Faces with normal in neg x direction |
+ 0..many |
+
+
+ #Z |
+ PerpendicularDirSelector |
+ Faces perpendicular to z direction |
+ 0..many |
+
+
+ %Plane |
+ TypeSelector |
+ Faces of type plane |
+ 0..many |
+
+
+ >Y |
+ DirectionMinMaxSelector |
+ Face farthest in the positive y dir |
+ 0 or 1 |
+
+
+ <Y |
+ DirectionMinMaxSelector |
+ Face farthest in the negative y dir |
+ 0 or 1 |
+
+
+
+
+
Examples of Filtering Edges
+ Some filter types are not supported for edges. The selector usually refers to the direction of the edge.
+ Non-linear edges are not selected for any selectors except type (%). Non-linear edges are never returned when these filters are applied.
+
+
+ Selector |
+ Selector Class |
+ Selects |
+ # Objects Returned |
+
+
+ +Z |
+ DirectionSelector |
+ Edges aligned in the Z direction |
+ 0..many |
+
+
+ |Z |
+ ParallelDirSelector |
+ Edges parallel to z direction |
+ 0..many |
+
+
+ -X |
+ DirectionSelector |
+ Edges aligned in neg x direction |
+ 0..many |
+
+
+ #Z |
+ PerpendicularDirSelector |
+ Edges perpendicular to z direction |
+ 0..many |
+
+
+ %Plane |
+ TypeSelector |
+ Edges type line |
+ 0..many |
+
+
+ >Y |
+ DirectionMinMaxSelector |
+ Edges farthest in the positive y dir |
+ 0 or 1 |
+
+
+ <Y |
+ DirectionMinMaxSelector |
+ Edges farthest in the negative y dir |
+ 0 or 1 |
+
+
+
+
+
Examples of Filtering Vertices
+ Only a few of the filter types apply to vertices. The location of the vertex is the subject of the filter.
+
+
+ Selector |
+ Selector Class |
+ Selects |
+ # Objects Returned |
+
+
+ >Y |
+ DirectionMinMaxSelector |
+ Vertices farthest in the positive y dir |
+ 0 or 1 |
+
+
+ <Y |
+ DirectionMinMaxSelector |
+ Vertices farthest in the negative y dir |
+ 0 or 1 |
+
+
+
+
+
+
diff --git a/CadQuery/Libs/cadquery/freecad_impl/shapes.py b/CadQuery/Libs/cadquery/freecad_impl/shapes.py
index 03e34b5..e0f2ecf 100644
--- a/CadQuery/Libs/cadquery/freecad_impl/shapes.py
+++ b/CadQuery/Libs/cadquery/freecad_impl/shapes.py
@@ -812,6 +812,21 @@ class Solid(Shape):
nativeEdges = [e.wrapped for e in edgeList]
return Shape.cast(self.wrapped.makeFillet(radius, nativeEdges))
+ def chamfer(self, length, length2, edgeList):
+ """
+ Chamfers the specified edges of this solid.
+ :param length: length > 0, the length (length) of the chamfer
+ :param length2: length2 > 0, optional parameter for asymmetrical chamfer. Should be `None` if not required.
+ :param edgeList: a list of Edge objects, which must belong to this solid
+ :return: Chamfered solid
+ """
+ nativeEdges = [e.wrapped for e in edgeList]
+ # note: we prefer 'length' word to 'radius' as opposed to FreeCAD's API
+ if length2:
+ return Shape.cast(self.wrapped.makeChamfer(length, length2, nativeEdges))
+ else:
+ return Shape.cast(self.wrapped.makeChamfer(length, nativeEdges))
+
def shell(self, faceList, thickness, tolerance=0.0001):
"""
make a shelled solid of given by removing the list of faces