2014-07-13 21:55:29 -04:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html >
< head >
< title > CadQuery Cheatsheet< / title >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" >
< style type = "text/css" >
.section {
margin: 0.5em;
padding: 0px 0.5em 0.5em;
background-color: #EBEBEB;
}
.column {
float: left;
width: 375px;
}
tr {
background-color: #FFFFFF;
}
td {
text-align: center;
width: 5em;
}
h2 {
display: inline;
}
< / style >
< / head >
< body >
2014-07-23 00:33:34 -04:00
< div class = "column" style = "width:475px;" >
2014-07-13 21:55:29 -04:00
< div class = "section" >
< h2 > Documentation< / h2 >
2014-07-23 00:33:34 -04:00
< ul style = "background-color:#ffffff;margin-bottom:0px;margin-top:0px;" >
2020-09-28 12:10:06 -04:00
< li > < a href = "https://cadquery.readthedocs.io/en/latest/" > CadQuery Documentation< / a > < / li >
< li > < a href = "https://github.com/CadQuery/cadquery/blob/master/README.md" > CadQuery Readme< / a > < / li >
< li > < a href = "https://github.com/CadQuery/cadquery/tree/master/examples" > CadQuery Examples< / a > < / li >
< li > < a href = "https://cadquery.readthedocs.io/en/latest/apireference.html" > CadQuery API Reference< / a > < / li >
2014-07-13 21:55:29 -04:00
< / ul >
< / div >
2014-07-18 23:15:43 -04:00
< div class = "section" >
< h2 > BREP Terminology< / h2 > < br / >
2014-07-23 00:33:34 -04:00
< table style = "width:100%;" >
2014-07-18 23:15:43 -04:00
< tr >
2014-07-23 00:33:34 -04:00
< td style = "width:10%;" > < strong > vertex< / strong > < / td >
< td style = "width:90%;" > A single point in space< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > edge< / strong > < / td >
< td > A connection between two or more vertices along a particular path (called a curve)< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > wire< / strong > < / td >
< td > A collection of edges that are connected together< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > face< / strong > < / td >
< td > A set of edges or wires that enclose a surface< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > shell< / strong > < / td >
< td > A collection of faces that are connected together along some of their edges< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > solid< / strong > < / td >
< td > A shell that has a closed interior< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < strong > compound< / strong > < / td >
< td > A collection of solids< / td >
2014-07-18 23:15:43 -04:00
< / tr >
< / table >
< / div >
2014-07-13 21:55:29 -04:00
< div class = "section" >
< h2 > Named Planes< / h2 > < br / >
2014-07-23 00:33:34 -04:00
Available named planes are as follows. Direction references refer to the global directions.
< table style = "width:100%;" >
2014-07-13 21:55:29 -04:00
< tr >
2014-07-23 00:33:34 -04:00
< th style = "width:25%;" > Name< / th >
< th style = "width:25%;" > xDir< / th >
< th style = "width:25%;" > yDir< / th >
< th style = "width:25%;" > zDir< / th >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
< td > XY< / td >
< td > +x< / td >
< td > +y< / td >
< td > +z< / td >
< / tr >
< tr >
< td > YZ< / td >
< td > +y< / td >
< td > +z< / td >
< td > +x< / td >
< / tr >
< tr >
< td > XZ< / td >
< td > +x< / td >
< td > +z< / td >
< td > -y< / td >
< / tr >
< tr >
< td > front< / td >
< td > +x< / td >
< td > +y< / td >
< td > +z< / td >
< / tr >
< tr >
< td > back< / td >
< td > -x< / td >
< td > +y< / td >
< td > -z< / td >
< / tr >
< tr >
< td > left< / td >
< td > +z< / td >
< td > +y< / td >
< td > -x< / td >
< / tr >
< tr >
< td > right< / td >
< td > -z< / td >
< td > +y< / td >
< td > +x< / td >
< / tr >
< tr >
< td > top< / td >
< td > +x< / td >
< td > -z< / td >
< td > +y< / td >
< / tr >
< tr >
< td > bottom< / td >
< td > +x< / td >
< td > +z< / td >
< td > -y< / td >
< / tr >
< / table >
< / div >
2014-07-28 08:04:06 -04:00
< div class = "section" >
< h2 > Core Classes< / h2 > < br / >
< table style = "width:100%;" >
< tr >
< th style = "width:40%;" > Class< / th >
< th style = "width:60%;" > Description< / th >
< / tr >
< tr >
< td > CQ(obj)< / td >
< td > Provides enhanced functionality for a wrapped CAD primitive.< / td >
< / tr >
< tr >
< td > Plane(origin, xDir, normal)< / td >
< td > A 2d coordinate system in space, with the x-y axes on the a plane, and a particular point as the origin.< / td >
< / tr >
< tr >
< td > Workplane(inPlane[origin, obj])< / td >
2021-08-20 15:44:42 +03:00
< td > Defines a coordinate system in space, in which 2D coordinates can be used.< / td >
2014-07-28 08:04:06 -04:00
< / tr >
< / table >
< / div >
2014-07-13 21:55:29 -04:00
< / div >
2014-07-23 00:33:34 -04:00
< div class = "column" style = "width:600px;" >
< div class = "section" >
< h2 > Selector Methods< / h2 > < br / >
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.< br / >
< table style = "width:100%;" >
< tr >
< th style = "width:40%;" > Selector Method< / th >
< th style = "width:60%;" > Description< / th >
< / tr >
< tr >
2020-09-28 12:10:06 -04:00
< td > < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.faces" > CQ.faces(selector=None)< / a > < / td >
2014-07-23 00:33:34 -04:00
< td > Select the faces of objects on the stack, optionally filtering the selection.< / td >
< tr >
2020-09-28 12:10:06 -04:00
< td > < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.edges" > CQ.edges(selector=None)< / a > < / td >
2014-07-23 00:33:34 -04:00
< td > Select the edges of objects on the stack, optionally filtering the selection.< / td >
< / tr >
< tr >
2020-09-28 12:10:06 -04:00
< td > < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.vertices" > CQ.vertices(selector=None)< / a > < / td >
2014-07-23 00:33:34 -04:00
< td > Select the vertices of objects on the stack, optionally filtering the selection.< / td >
< / tr >
< tr >
2020-09-28 12:10:06 -04:00
< td > < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.solids" > CQ.solids(selector=None)< / a > < / td >
2014-07-23 00:33:34 -04:00
< td > Select the solids of objects on the stack, optionally filtering the selection.< / td >
< / tr >
< tr >
2020-09-28 12:10:06 -04:00
< td > < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.shells" > CQ.shells(selector=None)< / a > < / td >
2014-07-23 00:33:34 -04:00
< td > Select the shells of objects on the stack, optionally filtering the selection.< / td >
< / tr >
< / table >
< / div >
2014-07-28 08:04:06 -04:00
< div class = "section" >
< h2 > Selector Classes< / h2 > < br / >
< table style = "width:100%;" >
< tr >
< th style = "width:40%;" > Class< / th >
< th style = "width:60%;" > Description< / th >
< / tr >
< tr >
< td > NearestToPointSelector(pnt)< / td >
< td > Selects object nearest the provided point.< / td >
< / tr >
< tr >
< td > ParallelDirSelector(vector[tolerance])< / td >
< td > Selects objects parallel with the provided direction.< / td >
< / tr >
< tr >
< td > DirectionSelector(vector[tolerance])< / td >
< td > Selects objects aligned with the provided direction.< / td >
< / tr >
< tr >
< td > PerpendicularDirSelector(vector[tolerance])< / td >
< td > Selects objects perpendicular with the provided direction.< / td >
< / tr >
< tr >
< td > TypeSelector(typeString)< / td >
< td > Selects objects of the prescribed topological type.< / td >
< / tr >
< tr >
< td > DirectionMinMaxSelector(vector[directionMax])< / td >
< td > Selects objects closest or farthest in the specified direction.< / td >
< / tr >
< tr >
< td > StringSyntaxSelector(selectorString)< / td >
< td > Filter lists objects using a simple string syntax.< / td >
< / tr >
< / table >
< / div >
2014-07-13 21:55:29 -04:00
< div class = "section" >
< h2 > Selector String Modifiers< / h2 > < br / >
2020-09-28 12:10:06 -04:00
Selectors are a complex topic: see < a href = "https://cadquery.readthedocs.io/en/latest/selectors.html" > CadQuery String Selectors< / a > for more information.< br / >
2014-07-13 21:55:29 -04:00
Axis Strings are: X, Y, Z, XY, YZ, XZ
2014-07-23 00:33:34 -04:00
< table style = "width:100%;" >
2014-07-13 21:55:29 -04:00
< tr >
2014-07-23 00:33:34 -04:00
< th style = "width:10%;" > Modifier< / th >
< th style = "width:90%;" > Description< / th >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > | < / td >
2020-09-28 12:10:06 -04:00
< td > Parallel to (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.ParallelDirSelector" > ParallelDirSelector< / a > ). Can return multiple objects.< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > # < / td >
2020-09-28 12:10:06 -04:00
< td > Perpendicular to (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.PerpendicularDirSelector" > PerpendicularDirSelector< / a > )< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > + < / td >
2020-09-28 12:10:06 -04:00
< td > Positive direction (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.DirectionSelector" > DirectionSelector< / a > )< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > - < / td >
2020-09-28 12:10:06 -04:00
< td > Negative direction (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.DirectionSelector" > DirectionSelector< / a > )< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > > < / td >
2020-09-28 12:10:06 -04:00
< td > Maximize (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.DirectionMinMaxSelector" > DirectionMinMaxSelector< / a > with directionMax=True)< / td >
2014-07-23 00:33:34 -04:00
< / tr >
< tr >
< td > < < / td >
2020-09-28 12:10:06 -04:00
< td > Minimize (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.DirectionMinMaxSelector" > DirectionMinMaxSelector< / a > with directionMax=False)< / td >
2014-07-23 00:33:34 -04:00
< / tr >
< tr >
< td > % < / td >
2020-09-28 12:10:06 -04:00
< td > Curve/surface type (same as < a href = "https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.TypeSelector" > TypeSelector< / a > )< / td >
2014-07-23 00:33:34 -04:00
< / tr >
< / table >
< / div >
< div class = "section" >
< h2 > Examples of Filtering Faces< / h2 > < br / >
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.
< table style = "width:100%;" >
< tr >
< th style = "width:10%;" > Selector< / th >
< th style = "width:40%;" > Selector Class< / th >
< th style = "width:40%;" > Selects< / th >
< th style = "width:10%;" > # Objects Returned< / th >
< / tr >
< tr >
< td > + Z< / td >
< td > DirectionSelector< / td >
< td > Faces with normal in +z direction< / td >
< td > 0 or 1< / td >
< / tr >
< tr >
< td > | Z< / td >
< td > ParallelDirSelector< / td >
< td > Faces parallel to xy plane< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > - X< / td >
< td > DirectionSelector< / td >
< td > Faces with normal in neg x direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > # Z< / td >
< td > PerpendicularDirSelector< / td >
< td > Faces perpendicular to z direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > % Plane< / td >
< td > TypeSelector< / td >
< td > Faces of type plane< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > > Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Face farthest in the positive y dir< / td >
< td > 0 or 1< / td >
< / tr >
< tr >
< td > < Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Face farthest in the negative y dir< / td >
< td > 0 or 1< / td >
< / tr >
< / table >
< / div >
< div class = "section" >
< h2 > Examples of Filtering Edges< / h2 > < br / >
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.
< table style = "width:100%;" >
< tr >
< th style = "width:10%;" > Selector< / th >
< th style = "width:40%;" > Selector Class< / th >
< th style = "width:40%;" > Selects< / th >
< th style = "width:10%;" > # Objects Returned< / th >
< / tr >
< tr >
< td > + Z< / td >
< td > DirectionSelector< / td >
< td > Edges aligned in the Z direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > | Z< / td >
< td > ParallelDirSelector< / td >
< td > Edges parallel to z direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > - X< / td >
< td > DirectionSelector< / td >
< td > Edges aligned in neg x direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > # Z< / td >
< td > PerpendicularDirSelector< / td >
< td > Edges perpendicular to z direction< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > % Plane< / td >
< td > TypeSelector< / td >
< td > Edges type line< / td >
< td > 0..many< / td >
< / tr >
< tr >
< td > > Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Edges farthest in the positive y dir< / td >
< td > 0 or 1< / td >
< / tr >
< tr >
< td > < Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Edges farthest in the negative y dir< / td >
< td > 0 or 1< / td >
< / tr >
< / table >
< / div >
< div class = "section" >
< h2 > Examples of Filtering Vertices< / h2 > < br / >
Only a few of the filter types apply to vertices. The location of the vertex is the subject of the filter.
< table style = "width:100%;" >
< tr >
< th style = "width:10%;" > Selector< / th >
< th style = "width:40%;" > Selector Class< / th >
< th style = "width:40%;" > Selects< / th >
< th style = "width:10%;" > # Objects Returned< / th >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > > Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Vertices farthest in the positive y dir< / td >
< td > 0 or 1< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< tr >
2014-07-23 00:33:34 -04:00
< td > < Y< / td >
< td > DirectionMinMaxSelector< / td >
< td > Vertices farthest in the negative y dir< / td >
< td > 0 or 1< / td >
2014-07-13 21:55:29 -04:00
< / tr >
< / table >
< / div >
< / div >
< / body >
< / html >