405 lines
15 KiB
HTML
405 lines
15 KiB
HTML
<!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>
|
|
<div class="column" style="width:475px;">
|
|
<div class="section">
|
|
<h2>Documentation</h2>
|
|
<ul style="background-color:#ffffff;margin-bottom:0px;margin-top:0px;">
|
|
<li><a href="http://parametricparts.com/docs/#">ParametricParts Documentation</a></li>
|
|
<li><a href="https://github.com/dcowden/cadquery/blob/master/README.md">CadQuery Readme</a></li>
|
|
<li><a href="http://parametricparts.com/docs/examples.html#examples">CadQuery Examples</a></li>
|
|
<li><a href="http://parametricparts.com/docs/classreference.html">CadQuery Class Reference</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section">
|
|
<h2>BREP Terminology</h2><br />
|
|
<table style="width:100%;">
|
|
<tr>
|
|
<td style="width:10%;"><strong>vertex</strong></td>
|
|
<td style="width:90%;">A single point in space</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>edge</strong></td>
|
|
<td>A connection between two or more vertices along a particular path (called a curve)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>wire</strong></td>
|
|
<td>A collection of edges that are connected together</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>face</strong></td>
|
|
<td>A set of edges or wires that enclose a surface</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>shell</strong></td>
|
|
<td>A collection of faces that are connected together along some of their edges</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>solid</strong></td>
|
|
<td>A shell that has a closed interior</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>compound</strong></td>
|
|
<td>A collection of solids</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="section">
|
|
<h2>Named Planes</h2><br />
|
|
Available named planes are as follows. Direction references refer to the global directions.
|
|
<table style="width:100%;">
|
|
<tr>
|
|
<th style="width:25%;">Name</th>
|
|
<th style="width:25%;">xDir</th>
|
|
<th style="width:25%;">yDir</th>
|
|
<th style="width:25%;">zDir</th>
|
|
</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>
|
|
<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>
|
|
<td>Defines a coordinate system in space, in which 2-d coordinates can be used.</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<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>
|
|
<td><a href="http://parametricparts.com/docs/classreference.html#cadfile.cadutils.cadquery.CQ.faces">CQ.faces(selector=None)</a></td>
|
|
<td>Select the faces of objects on the stack, optionally filtering the selection.</td>
|
|
<tr>
|
|
<td><a href="http://parametricparts.com/docs/classreference.html#cadfile.cadutils.cadquery.CQ.edges">CQ.edges(selector=None)</a></td>
|
|
<td>Select the edges of objects on the stack, optionally filtering the selection.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="http://parametricparts.com/docs/classreference.html#cadfile.cadutils.cadquery.CQ.vertices">CQ.vertices(selector=None)</a></td>
|
|
<td>Select the vertices of objects on the stack, optionally filtering the selection.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="http://parametricparts.com/docs/classreference.html#cadfile.cadutils.cadquery.CQ.solids">CQ.solids(selector=None)</a></td>
|
|
<td>Select the solids of objects on the stack, optionally filtering the selection.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="http://parametricparts.com/docs/classreference.html#cadfile.cadutils.cadquery.CQ.shells">CQ.shells(selector=None)</a></td>
|
|
<td>Select the shells of objects on the stack, optionally filtering the selection.</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<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>
|
|
<div class="section">
|
|
<h2>Selector String Modifiers</h2><br />
|
|
Selectors are a complex topic: see <a href="http://parametricparts.com/docs/selectors.html">CadQuery String Selectors</a> for more information.<br />
|
|
Axis Strings are: X, Y, Z, XY, YZ, XZ
|
|
<table style="width:100%;">
|
|
<tr>
|
|
<th style="width:10%;">Modifier</th>
|
|
<th style="width:90%;">Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td>|</td>
|
|
<td>Parallel to (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=paralleldirselector#cadfile.cadutils.cadquery.ParallelDirSelector">ParallelDirSelector</a>). Can return multiple objects.</td>
|
|
</tr>
|
|
<tr>
|
|
<td>#</td>
|
|
<td>Perpendicular to (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=perpendiculardirselector#cadfile.cadutils.cadquery.PerpendicularDirSelector">PerpendicularDirSelector</a>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>+</td>
|
|
<td>Positive direction (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=directionselector#cadfile.cadutils.cadquery.DirectionSelector">DirectionSelector</a>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>-</td>
|
|
<td>Negative direction (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=directionselector#cadfile.cadutils.cadquery.DirectionSelector">DirectionSelector</a>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>></td>
|
|
<td>Maximize (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=directionminmaxselector#cadfile.cadutils.cadquery.DirectionMinMaxSelector">DirectionMinMaxSelector</a> with directionMax=True)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><</td>
|
|
<td>Minimize (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=directionminmaxselector#cadfile.cadutils.cadquery.DirectionMinMaxSelector">DirectionMinMaxSelector</a> with directionMax=False)</td>
|
|
</tr>
|
|
<tr>
|
|
<td>%</td>
|
|
<td>Curve/surface type (same as <a href="http://parametricparts.com/docs/classreference.html?highlight=typeselector#cadfile.cadutils.cadquery.TypeSelector">TypeSelector</a>)</td>
|
|
</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>
|
|
</tr>
|
|
<tr>
|
|
<td>>Y</td>
|
|
<td>DirectionMinMaxSelector</td>
|
|
<td>Vertices farthest in the positive y dir</td>
|
|
<td>0 or 1</td>
|
|
</tr>
|
|
<tr>
|
|
<td><Y</td>
|
|
<td>DirectionMinMaxSelector</td>
|
|
<td>Vertices farthest in the negative y dir</td>
|
|
<td>0 or 1</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|