CadQuery-- a parametric cad script framework
.. image:: http://dcowden.github.io/cadquery/static/cadquerylogo_dark.svg
Version 2.0 development is under way It uses pythonOCC instead of FreeCAD, and has tons of cool features
BUT DONT WORRY! Version 1.x (this repository ) will be suported until all features are comfortably implemented in the 2.x stream.
We're happy to be moving to a more open organization, but we're sad we're starting over with our stars. Please give us one at our new home!
|TRAVIS| |APPVEYOR| |COVERALLS| |VERSION| |LICENSE|
.. |TRAVIS| image:: https://travis-ci.org/dcowden/cadquery.svg?branch=master :alt: Travis Build Status :target: https://travis-ci.org/dcowden/cadquery?branch=master
.. |APPVEYOR| image:: https://ci.appveyor.com/api/projects/status/c7u4yjl8xxlokrw0/branch/master?svg=true :alt: Build status :target: https://ci.appveyor.com/project/jmwright/cadquery/branch/master
.. |COVERALLS| image:: https://coveralls.io/repos/github/dcowden/cadquery/badge.svg?branch=master :alt: Coverage Status :target: https://coveralls.io/github/dcowden/cadquery?branch=master
.. |VERSION| image:: https://d25lcipzij17d.cloudfront.net/badge.svg?id=gh&type=6&v=1.2.0&x2=0 :alt: GitHub version :target: https://github.com/dcowden/cadquery/releases/tag/v1.2.0
.. |LICENSE| image:: https://img.shields.io/badge/license-Apache2-blue.svg :alt: License :target: https://github.com/dcowden/cadquery/blob/master/LICENSE
CadQuery has several goals:
Using CadQuery, you can write short, simple scripts that produce high quality CAD models. It is easy to make many different objects using a single script that can be customized.
You can find the full cadquery documentation at
We also have a Google Group to make it easy to get help from other CadQuery users. We want you to feel welcome and encourage you to join the group and introduce yourself. We would also love to hear what you are doing with CadQuery. https://groups.google.com/forum/#!forum/cadquery
Installation instructions for all following use cases can be found
It is currently possible to use CadQuery for your own projects in 4 different ways: * as a plugin for FreeCAD * using the Docker Image to operate CadQuery as a CLI * as a plugin running on a Jupyter Notebook server * a standalone installation
If you are interested in trying CadQuery without installing anything, your best option is to experiment with CadQuery scripts running on a Jupyter server.
.. |BINDER| image:: https://mybinder.org/badge.svg :alt: Binder :target: https://mybinder.org/v2/gh/RustyVermeer/tryCQ/master
That button will launch a Jupyter Server pre-configured with CadQuery and its dependencies. It contains a folder with many useful examples to showcase CadQuery's features.
The easiest way to get started with CadQuery is to Install FreeCAD (version 16+) (
http://www.freecadweb.org/), and then to use our great CadQuery-FreeCAD plugin here:
It includes the latest version of cadquery already bundled, and has super-easy installation on Mac, Windows, and Unix.
It has tons of awesome features like integration with FreeCAD so you can see your objects, code-autocompletion, an examples bundle, and script saving/loading. Its definitely the best way to kick the tires!
Awesome! CadQuery is built with this attitude in mind. If none of the existing usage methods work for you, you are more than welcome to forge your own path. You'll probably find the most success using the Docker image. You can alternatively install CadQuery as a standalone package.
The CadQuery docker image (
https://hub.docker.com/r/dcowden/cadquery/_) includes cadquery and all of its dependencies. It can be used to run cadquery scripts without any installation required ( other than docker, of course)
Display the Documentation:
.. code-block:: bash
docker run dcowden/cadquery:latest
Build a local model using stdin/stdout:
.. code-block:: bash
cat Ex001_Simple_Block.py | docker run -i dcowden/cadquery:latest build --in_spec stdin --format STEP --out_spec stdout
... STEP output on the console
Build local models and output to the same directory::
docker run -v $PWD:/home/cq -i dcowden/cadquery:latest build --in_spec Ex001_Simple_Block.py --format STEP INFO: Reading from file 'Ex001_Simple_Block.py' INFO: Parsed Script 'Ex001_Simple_Block.py'. INFO: This script provides parameters length,thickness,height, which can be customized at build time. INFO: The script will run with default variable values INFO: use --param_file to provide a json file that contains values to override the defaults INFO: Output Format is 'STEP'. Use --output-format to change it. INFO: Output Path is './cqobject-%(counter)d.%(format)s'. Use --out_spec to change it. INFO: Script Generated 1 result Objects INFO: Writing STEP Output to './cqobject-1.STEP'
This resin mold was modeled using cadquery and then created on a CNC machine:
.. |HY0ZDCABLEFIX| image:: http://dcowden.github.io/cadquery/static/hyOzd-cablefix.png :alt: Cable-fix resin mold: Rendered
.. |HY0ZDFINISHED| image:: http://dcowden.github.io/cadquery/static/hyOzd-finishedthumb.jpg :alt: Cable-fix resin mold: Finised :target: http://dcowden.github.io/cadquery/static/hyOzd-finished_thumb.jpg
The cadquery script is surprisingly short, and allows easily customizing any of the variables:
.. code-block:: python
import cadquery as cq from Helpers import show BS = cq.selectors.BoxSelector
mount_holes = True
mw = 40 mh = 13 ml = 120
wire and fix size
wd = 6 # wire diameter rt = 7 # resin thickness rl = 50 # resin length rwpl = 10 # resin to wire pass length
pf = 18
mhd = 7 # hole diameter mht = 3 # hole distance from edge
fhd = 6
base = cq.Workplane("XY").box(ml, mw, mh, (True, True, False))
pocket = cq.Workplane("XY", (0, 0, mh)).moveTo(-ml/2., 0).line(0, wd/2.)
.line((ml-rl)/2.-rwpl, 0).line(rwpl, rt).line(rl, 0)
.line(rwpl, -rt).line((ml-rl)/2.-rwpl, 0)
.line(0, -(wd/2.)).close().revolve(axisEnd=(1, 0))
.edges(BS((-rl/2.-rwpl-.1, -100, -100), (rl/2.+rwpl+.1, 100, 100)))
r = base.cut(pocket)
if mount_holes: px = ml/2.-mht-mhd/2. py = mw/2.-mht-mhd/2 r = r.faces("
Thanks go to cadquery contributor hyOzd ( Altu Technology ) for the example!
KiCad uses cadquery to build high quality models of electronic components. (https://github.com/KiCad/packages3D_)
.. image:: http://dcowden.github.io/cadquery/static/KiCadCapacitorsSMDthumb.jpg :target: http://dcowden.github.io/cadquery/static/KiCadCapacitors_SMD.jpg :alt: Surface mount capacitors rendered in KiCad
This Prusa i3 extruder support uses cadquery to build the model (https://github.com/adam-urbanczyk/cadquery-models_):
.. image:: http://dcowden.github.io/cadquery/static/extrudersupport.png :alt: Prusa i3 extruder support - FreeCAD model render
The mach30 project used cadquery to develop a tool that will create a rocket thruster directly from the appropriate equations (https://opendesignengine.net/projects/yavin-thruster/wiki_):
.. image:: http://dcowden.github.io/cadquery/static/march30landing_page.png :target: https://opendesignengine.net/projects/yavin-thruster/wiki :alt: mach30 project landing page
This example uses Jupyter notebook to produce a really cool web-based scripting environment (https://github.com/RustyVermeer/avnb/blob/master/readme.md_):
.. image:: http://dcowden.github.io/cadquery/static/jupytershowcase_thumb.png :alt: Jupyter notebook showcased as animation :target: https://github.com/RustyVermeer/cqnb
We would love to link to your cadquery based project. Just let us know and we'll add it here.
Where does the name CadQuery come from?
If you are familiar with jQuery, you will probably recognize several jQuery features that CadQuery uses:
CadQuery is based on OpenCasCade. CadQuery shares many features with OpenSCAD, another open source, script based, parametric model generator.
The primary advantage of OpenSCAD is the large number of already existing model libraries that exist already. So why not simply use OpenSCAD?
CadQuery scripts have several key advantages over OpenSCAD:
This includes many standard libraries and IDEs
by OCC include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, in addition to the standard CSG operations supported by CGAL
and then add parametric features is key. This is possible in OpenSCAD using STL, but STL is a lossy format
features based on the position of other features, workplanes, vertices, etc.
CadQuery is licensed under the terms of the
Apache Public License, version 2.0_.
Cadquery 2.0 is under way. 2.0 is based on pythonOCC directly ( rather than FreeCAD ), and is under heavy development. Beginning with version 2.0, CadQuery has moved to a new home at
Work is underway on a stand-alone gui here:
Work by Fragmuffin is ongoing with the
Adam Urbańczyk has been working hard on his own
CQ fork_ which uses only PythonOCC instead of FreeCAD.
Work has begun on Cadquery 2.0, which will feature:
The project page can be found here:
A more detailed description of
the plan for CQ 2.0_