API Reference
The CadQuery API is made up of 4 main objects:
Sketch – Construct 2D sketches
Workplane – Wraps a topological entity and provides a 2D modelling context.
Selector – Filter and select things
Assembly – Combine objects into assemblies.
This page lists methods of these objects grouped by functional area
See also
This page lists api methods grouped by functional area. Use CadQuery Class Summary to see methods alphabetically by class.
Sketch initialization
Creating new sketches.
|
2D sketch. |
|
Import a DXF file and construct face(s) |
Initialize and return a sketch |
|
Finish sketch construction and return the parent. |
|
Create a partial copy of the sketch. |
|
|
Create a partial copy of the sketch with a new location. |
Create a partial copy of the sketch with moved _faces. |
Sketch selection
Selecting, tagging and manipulating elements.
|
Tag current selection. |
|
Select based on tags. |
Reset current selection. |
|
Delete selected object. |
|
|
Select faces. |
|
Select edges. |
|
Select vertices. |
Sketching with faces
Sketching using the face-based API.
|
Construct a face from a wire or edges. |
|
Construct a rectangular face. |
|
Construct a circular face. |
|
Construct an elliptical face. |
|
Construct a trapezoidal face. |
|
Construct a slot-shaped face. |
|
Construct a regular polygonal face. |
|
Construct a polygonal face. |
|
Generate a rectangular array of locations. |
|
Generate a polar array of locations. |
|
Distribute locations along selected edges or wires. |
|
Apply a callback on all applicable entities. |
|
Set current selection to given locations or points. |
|
Generate a convex hull from current selection or all objects. |
|
Offset selected wires or edges. |
Add a fillet based on current selection. |
|
Add a chamfer based on current selection. |
|
Remove internal wires. |
Sketching with edges and constraints
Sketching using the edge-based API.
|
Add an edge to the sketch. |
|
Construct a segment. |
|
Construct an arc. |
|
Construct a spline edge. |
|
Connect last edge to the first one. |
|
Assemble edges into faces. |
|
Add a constraint. |
Solve current constraints and update edge positions. |
Initialization
Creating new workplanes and object chains
|
Defines a coordinate system in space, in which 2D coordinates can be used. |
2D Operations
Creating 2D constructs that can be used to create 3D features.
All 2D operations require a Workplane object to be created.
|
Shift local coordinates to the specified location. |
|
Make a line from the current point to the provided point |
|
Make a line from the current point to the provided point, using dimensions relative to the current point |
|
Make a vertical line from the current point the provided distance |
|
Make a vertical line from the current point to the provided y coordinate. |
|
Make a horizontal line from the current point the provided distance |
|
Make a horizontal line from the current point to the provided x coordinate. |
|
Make a line of the given length, at the given angle from the current point |
|
Make a line from the current point to the given polar coordinates |
|
Move to the specified point, without drawing. |
|
Move the specified distance from the current point, without drawing. |
|
Create a spline interpolated through the provided points (2D or 3D). |
|
Create a spline curve approximating the provided function. |
|
Create a spline surface approximating the provided function. |
|
Draw an arc from the current point, through point1, and ending at point2 |
|
Draw an arc from the current point to endPoint with an arc defined by the sag (sagitta). |
|
Draw an arc from the current point to endPoint with an arc defined by the radius. |
|
Draw an arc as a tangent from the end of the current edge to endpoint. |
Mirror entities around the y axis of the workplane plane. |
|
Mirror entities around the x axis of the workplane plane. |
|
|
Returns a CQ object with all pending edges connected into a wire. |
|
Make a rectangle for each item on the stack. |
|
Make a circle for each item on the stack. |
|
Make an ellipse for each item on the stack. |
|
Draw an elliptical arc with x and y radiuses either with start point at current point or or current point being the center of the arc |
|
Create a polyline from a list of points |
End construction, and attempt to build a closed wire. |
|
|
Creates an array of points and pushes them onto the stack. |
|
Creates a polar array of points and pushes them onto the stack. |
|
Creates a rounded slot for each point on the stack. |
|
Creates a 2D offset wire. |
|
Place the provided sketch(es) based on the current items on the stack. |
3D Operations
Some 3D operations also require an active 2D workplane, but some do not.
3D operations that require a 2D workplane to be active:
|
Makes a counterbored hole for each item on the stack. |
|
Makes a countersunk hole for each item on the stack. |
|
Makes a hole for each item on the stack. |
|
Use all un-extruded wires in the parent chain to create a prismatic solid. |
|
Cuts the provided solid from the current solid, IE, perform a solid subtraction. |
|
Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid. |
|
Use all un-extruded wires in the parent chain to create a prismatic cut from existing solid. |
|
Return a 3d box with specified dimensions for each object on the stack. |
|
Returns a 3D sphere with the specified radius for each point on the stack. |
|
Returns a 3D wedge with the specified dimensions for each point on the stack. |
|
Returns a cylinder with the specified radius and height for each point on the stack |
|
Unions all of the items on the stack of toUnion with the current solid. |
|
Attempts to combine all of the items on the stack into a single item. |
|
Intersects the provided solid from the current solid. |
|
Make a lofted solid, through the set of wires. |
|
Use all un-extruded wires in the parent chain to create a swept solid. |
|
Extrudes a wire in the direction normal to the plane, but also twists by the specified angle over the length of the extrusion. |
|
Use all un-revolved wires in the parent chain to create a solid. |
|
Returns a 3D text. |
3D operations that do NOT require a 2D workplane to be active:
|
Remove the selected faces to create a shell of the specified thickness. |
|
Fillets a solid on the selected edges. |
|
Chamfers a solid on the selected edges. |
Splits a solid on the stack into two parts, optionally keeping the separate parts. |
|
|
Returns a copy of all of the items on the stack rotated through and angle around the axis of rotation. |
|
Rotates all items on the stack by the specified angle, about the specified axis |
|
Returns a copy of all of the items on the stack moved by the specified translation vector. |
|
Mirror a single CQ object. |
File Management and Export
|
Returns svg text that represents the first item on the stack. |
|
Exports the first item on the stack as an SVG file |
|
Accepts a file name and loads the STEP file into a cadquery Workplane |
|
Loads a DXF file into a Workplane. |
|
Export Workplane or Shape to file. |
Create DXF document from CadQuery objects. |
Iteration Methods
Methods that allow iteration over the stack or objects
|
Runs the provided function on each value in the stack, and collects the return values into a new CQ object. |
|
Same as each(), except arg is translated by the positions on the stack. |
Stack and Selector Methods
CadQuery methods that operate on the stack
Return a list of all CQ objects on the stack. |
|
Return the number of objects currently on the stack |
|
get the values in the current list |
|
Adds an object or a list of objects to the stack |
|
Return the first value on the stack. |
|
Return the first item on the stack |
|
Return the ith item on the stack. |
|
Return the last item on the stack. |
|
|
Return the nth parent of this CQ element |
|
Select the vertices of objects on the stack, optionally filtering the selection. |
|
Select the faces of objects on the stack, optionally filtering the selection. |
|
Select the edges of objects on the stack, optionally filtering the selection. |
|
Select the wires of objects on the stack, optionally filtering the selection. |
|
Select the solids of objects on the stack, optionally filtering the selection. |
|
Select the shells of objects on the stack, optionally filtering the selection. |
|
Select compounds on the stack, optionally filtering the selection. |
Selectors
Objects that filter and select CAD objects. Selectors are used to select existing geometry as a basis for further operations.
Selects object nearest the provided point. |
|
|
Selects objects inside the 3D box defined by 2 points. |
|
A selector that handles selection on the basis of a single direction vector. |
|
Selects objects parallel with the provided direction. |
|
Selects objects aligned with the provided direction. |
|
Filters for objects parallel (or normal) to the specified direction then returns the Nth one. |
|
Select the object(s) with the Nth length |
|
Selects the object(s) with Nth area |
|
Select the object with the Nth radius. |
|
Selects objects perpendicular with the provided direction. |
|
Selects objects having the prescribed geometry type. |
|
Selects objects closest or farthest in the specified direction. |
|
Sorts objects into a list with order determined by the distance of their center projected onto the specified direction. |
|
Base class for selectors that operates with two other selectors. |
|
Intersection selector. |
|
Union selector. |
|
Difference selector. |
|
Inverts the selection of given selector. |
|
Filter lists objects using a simple string syntax. |
Assemblies
Workplane and Shape objects can be connected together into assemblies
|
Nested assembly of Workplane and Shape objects defining their relative positions. |
Add a subassembly to the current assembly. |
|
|
Save assembly to a file. |
Define a new constraint. |
|
|
Solve the constraints. |
alias of |
|
|
Wrapper for the OCCT color object Quantity_ColorRGBA. |