CadQuery API Reference

See also

This page lists api methods grouped by functional area. Use CadQuery Class Reference to see methods alphabetically by class. Don’t see a method you want? see Extending CadQuery

Primary Objects

The CadQuery API is made up of 3 main objects:

  • CQ - Basic Selection, and 3d operations
  • Workplane – Draw in 2-d to make 3d features
  • Selector – Filter and select things

The sections below list methods of these objects grouped by functional area

Initialization

Creating new workplanes and object chains

CQ(obj) Provides enhanced functionality for a wrapped CAD primitive.
Workplane(inPlane[, origin, obj]) Defines a coordinate system in space, in which 2-d coordinates can be used.
CQ.workplane([offset, invert]) Creates a new 2-D workplane, located relative to the first face on the stack.

2-d Operations

Creating 2-d constructs that can be used to create 3 d features

Workplane.center(x, y) Shift local coordinates to the specified location.
Workplane.lineTo(x, y[, forConstruction]) Make a line from the current point to the provided point
Workplane.line(xDist, yDist[, forConstruction]) Make a line from the current point to the provided point, using
Workplane.vLine(distance[, forConstruction]) Make a vertical line from the current point the provided distance
Workplane.vLineTo(yCoord[, forConstruction]) Make a vertcial line from the current point to the provided y coordinate.
Workplane.hLine(distance[, forConstruction]) Make a horizontal line from the current point the provided distance
Workplane.moveTo([x, y]) Move to the specified point, without drawing.
Workplane.move([xDist, yDist]) Move the specified distance from the current point, without drawing.
Workplane.spline(listOfXYTuple[, ...]) Create a spline interpolated through the provided points.
Workplane.threePointArc(point1, point2[, ...]) Draw an arc from the current point, through point1, and ending at point2
Workplane.rotateAndCopy(matrix) Makes a copy of all edges on the stack, rotates them according to the provided matrix, and then attempts to consolidate them into a single wire.
Workplane.mirrorY() Mirror entities around the y axis of the workplane plane.
Workplane.mirrorX() Mirror entities around the x axis of the workplane plane.
Workplane.wire([forConstruction]) Returns a CQ object with all pending edges connected into a wire.
Workplane.rect(xLen, yLen[, centered, ...]) Make a rectangle for each item on the stack.
Workplane.circle(radius[, forConstruction]) Make a circle for each item on the stack.
Workplane.polyline(listOfXYTuple[, ...]) Create a polyline from a list of points
Workplane.close() End 2-d construction, and attempt to build a closed wire.
Workplane.rarray(xSpacing, ySpacing, xCount, ...) Creates an array of points and pushes them onto the stack.

3-d Operations

Methods that create 3d features

Workplane.cboreHole(diameter, cboreDiameter, ...) Makes a counterbored hole for each item on the stack.
Workplane.cskHole(diameter, cskDiameter, ...) Makes a countersunk hole for each item on the stack.
Workplane.hole(diameter[, depth]) Makes a hole for each item on the stack.
Workplane.extrude(distance[, combine]) Use all un-extruded wires in the parent chain to create a prismatic solid.
Workplane.cut(toCut[, combine]) Cuts the provided solid from the current solid, IE, perform a solid subtraction
Workplane.cutBlind(distanceToCut) Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid.
Workplane.cutThruAll([positive]) Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid.
Workplane.box(length, width, height[, ...]) Return a 3d box with specified dimensions for each object on the stack.
Workplane.union([toUnion, combine]) Unions all of the items on the stack of toUnion with the current solid.
Workplane.combine() Attempts to combine all of the items on the items on the stack into a single item.
CQ.shell(thickness) Remove the selected faces to create a shell of the specified thickness.
CQ.fillet(radius) Fillets a solid on the selected edges.
CQ.split([keepTop, keepBottom]) Splits a solid on the stack into two parts, optionally keeping the separate parts.
CQ.rotateAboutCenter(axisEndPoint, angleDegrees) Rotates all items on the stack by the specified angle, about the specified axis
CQ.translate(vec) Returns a copy of all of the items on the stack by the specified distance

Iteration Methods

Methods that allow iteration over the stack or objects

Workplane.each(callBackFunction[, ...]) runs the provided function on each value in the stack, and collects the return values into a new CQ
Workplane.eachpoint(callbackFunction[, ...]) Same as each(), except each item on the stack is converted into a point before it is passed into the callback function.

Stack Methods

CadQuery methods that operate on the stack

CQ.all() Return a list of all CQ objects on the stack.
CQ.size() Return the number of objects currently on the stack
CQ.vals() get the values in the current list
CQ.add(obj) adds an object or a list of objects to the stack
CQ.val() Return the first value on the stack :return: the first value on the stack.
CQ.first() Return the first item on the stack :returns: the first item on the stack.
CQ.item(i) Return the ith item on the stack.
CQ.last() Return the last item on the stack.
CQ.end() Return the parent of this CQ element
CQ.vertices([selector]) Select the vertices of objects on the stack, optionally filtering the selection.
CQ.faces([selector]) Select the faces of objects on the stack, optionally filtering the selection.
CQ.edges([selector]) Select the edges of objects on the stack, optionally filtering the selection.
CQ.wires([selector]) Select the wires of objects on the stack, optionally filtering the selection.
CQ.solids([selector]) Select the solids of objects on the stack, optionally filtering the selection.
CQ.shells([selector]) Select the shells of objects on the stack, optionally filtering the selection.
CQ.compounds([selector]) Select compounds on the stack, optionally filtering the selection.

Selectors

Objects that filter and select CAD objects

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.

Table Of Contents

Previous topic

CadQuery Examples

Next topic

Primitive Class Reference