Package: cadquery
CadQueryQuick LinksDocumentation|Cheatsheet|Discord|Google Group|GUI EditorWhat is CadQueryCadQuery is an intuitive, easy-to-use Python module for building parametric 3D CAD models. 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.CadQuery is often compared toOpenSCAD. Like OpenSCAD, CadQuery is an open-source, script based, parametric model generator. However, CadQuery stands out in many ways and has several key advantages:The scripts use a standard programming language, Python, and thus can benefit from the associated infrastructure. This includes many standard libraries and IDEs.CadQuery's CAD kernel Open CASCADE Technology (OCCT) is much more powerful than theCGALused by OpenSCAD. Features supported natively by OCCT include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, in addition to the standard CSG operations supported by CGALAbility to import/exportSTEPand the ability to begin with a STEP model, created in a CAD package, and then add parametric features. This is possible in OpenSCAD using STL, but STL is a lossy format.CadQuery scripts require less code to create most objects, because it is possible to locate features based on the position of other features, workplanes, vertices, etc.CadQuery scripts can build STL, STEP, AMF and 3MF faster than OpenSCAD.CadQuery was built to be used as a Python library without any GUI. This makes it great for use cases such as integration into servers, or creating scientific and engineering scripts.  Options for visualziation are also available including CQ-Editor and JupyterLab.For those who are interested, theOCP repositorycontains the current OCCT wrapper used by CQ.Key featuresBuild 3D models with scripts that are as close as possible to how you would describe the object to a human.Create parametric models that can be very easily customized by end users.Output high quality (loss-less) CAD formats like STEP and DXF in addition to STL, VRML, AMF and 3MF.Provide a non-proprietary, plain text model format that can be edited and executed with only a web browser.Offer advanced modeling capabilities such as fillets, curvilinear extrudes, parametric curves and lofts.Build nested assemblies out of individual parts and other assemblies.Why this forkThe original version of CadQuery was built on the FreeCAD API. This was great because it allowed for fast development and easy cross-platform capability. However, we eventually started reaching the limits of the API for some advanced operations and selectors. This 2.0 version of CadQuery is based directly on a Python wrapper of the OCCT kernel. This gives us a great deal more control and flexibility, at the expense of some simplicity and having to handle the cross-platform aspects of deployment ourselves. We believe this is a worthwhile trade-off to allow CadQuery to continue to grow and expand in the future.Getting startedTo learn more about designing with CadQuery, visit thedocumentation,examples, andcheatsheet.To get started playing around with CadQuery and see its capabilities, take a look at theCQ-editor GUI. This easy-to-use IDE is a great way to get started desiging with CadQuery.  The CQ-editor installer bundles both CQ-editor and CadQuery (recommended).  See theCQ-editor installation instructions.The CadQuery library (with or without CQ-editor) and its dependencies may be installed using conda, or pip.  Note that conda (or the CQ-editor installer) is the better supported option.See the documentation for detailed CadQueryinstallation instructions.There are also videos covering installation:Linuxinstallation videoWindowsinstallation videoCadQuery Installation Via CondaTo first install the Conda package manager seeInstall the Conda Package Manager, andMambaforgefor a minimal installer.mamba installis recommended overconda installfor faster and less memory intensive cadquery installation.# Set up a new environment
conda create -n cadquery

# Activate the new environment
conda activate cadquery

# Install the latest released version
mamba install -c conda-forge cadquery

# Or install the dev version to get the latest changes
mamba install -c conda-forge -c cadquery cadquery=masterCadQuery Installation Via PipCadQuery has a complex set of dependencies including OCP, which is our set of bindings to the OpenCASCADE CAD kernel. OCP is distributed as binary wheels for Linux, MacOS and Windows. However, there are some limitations. Only Python 3.8 through 3.10 are currently supported, and some older Linux distributions such as Ubuntu 18.04 are not supported. If the pip installation method does not work for your system, you can try the conda installation method.It is highly recommended that a virtual environment is used when installing CadQuery, although it is not strictly required. Installing CadQuery via pip requires a up-to-date version of pip, which can be obtained with the following command line (or a slight variation thereof).python3 -m pip install --upgrade pipOnce a current version of pip is installed, CadQuery can be installed using the following command line.pip install cadqueryIt is also possible to install the very latest changes directly from CadQuery's GitHub repository, with the understanding that sometimes breaking changes can occur. To install from the git repository, run the following command line.pip install git+https://github.com/CadQuery/cadquery.gitCQ-editor GUICQ-editor is an IDE that allows users to edit CadQuery model scripts in a GUI environment. It includes features such as:A graphical debugger that allows you to step through your scripts.A CadQuery stack inspector.Export to various formats, including STEP and STL, directly from the menu.More on CQ-editor:CQ-editor READMEInstallationJupyterCadQuery supports Jupyter out-of-the-box.  Run your CadQuery code in the notebook and visualize the model by callingdisplay(<CadQuery object>).JupyterLab installation.Getting helpYou can find the full CadQuery documentation atcadquery.readthedocs.io.We also have aGoogle Groupto 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.There is aDiscord serveras well. You can ask for help in thegeneralchannel.Projects using CadQueryHere are just a few examples of how CadQuery is being used.FxBricks Lego Train SystemFxBricksuses CadQuery in the product development pipeline for their Lego train system. FxBricks has also given back to the community by creatingdocumentation for their CAD pipeline. They have also assembledcq-kit, a library containing utility classes and functions to extend the capabilities of CadQuery. Thanks to @michaelgale and @fx-bricks for this example.Hexidor Board Game DevelopmentHexidor is an expanded take on the Quoridor board game, and the development process has been chronicledhere. CadQuery was used to generate the game board. Thanks to Bruce for this example.Spindle assemblyThanks to @marcus7070 for this example fromhere.3D Printed Resin MoldThanks to @eddieliberato for sharingthis exampleof an anti-kink resin mold for a cable.LicenseCadQuery is licensed under the terms of theApache Public License, version 2.0.ContributingContributions from the community are welcome and appreciated.You do not need to be a software developer to have a big impact on this project. Contributions can take many forms including, but not limited to, the following:Writing and improving documentationTriaging bugsSubmitting bugs and feature requestsCreating tutorial videos and blog postsHelping other users get started and solve problemsTelling others about this projectHelping with translations and internationalizationHelping with accessibilityContributing bug fixes and new featuresIt is asked that all contributions to this project be made in a respectful and considerate way. Please use thePython Community Code of Conduct'sguidelines as a reference.Contributing codeIf you are going to contribute code, make sure to follow this steps:Consider opening an issue first to discuss what you have in mindTry to keep it as short and simple as possible (if you want to change several
things, start with just one!)Fork the CadQuery repository, clone your fork and create a new branch to
start working on your changesCreate a conda development environment with something like:mamba env create -n cq-dev -f environment.ymlActivate the new conda environment:conda activate cq-devIf desired, install the master branch of cq-editor (Note; a release version may not be compatible with the master branch of cadquery):mamba install -c cadquery -c conda-forge cq-editor=masterInstalling cq-editor adds another instance of cadquery which overrides the clone just added. Fix this by reinstalling cadquery using pip:pip install -e .Before making any changes verify that the current tests pass. Runpytestfrom the root of your cadquery clone, there should be no failures and the output will look similar to this:======= 215 passed, 57 warnings in 13.95s =======Start with the tests! How should CadQuery behave after your changes? Make
sure to add some tests to the test suite to ensure proper behaviorMake sure your tests have assertions checking all the expected resultsAdd a nice docstring to the test indicating what the test is doing; if there
is too much to explain, consider splitting the test in two!Go ahead and implement the changesAdd a nice docstring to the functions/methods/classes you implement
describing what they do, what the expected parameters are and what it returns
(if anything)Update the documentation if there is any change to the public APIConsider adding an example to the documentation showing your cool new
feature!Make sure nothing is broken (run the complete test suite withpytest)Runblackfromour forkto autoformat your code and make sure your code style complies
with CadQuery'sPush the changes to your fork and open a pull-request upstreamKeep an eye on the automated feedback you will receive from the CI pipelines;
if there is a test failing or some code is not properly formatted, you will
be notified without human interventionBe prepared for constructive feedback and criticism!Be patient and respectful, remember that those reviewing your code are also
working hard (sometimes reviewing changes is harder than implementing them!)How to Report a BugWhen filing a bug reportissue, please be sure to answer these questions:What version of the software are you running?What operating system are you running the software on?What are the steps to reproduce the bug?How to Suggest a Feature or EnhancementIf you find yourself wishing for a feature that does not exist, you are probably not alone. There are bound to be others out there with similar needs. Open anissuewhich describes the feature you would like to see, why you need it, and how it should work.