Git Product home page Git Product logo

cadquery's Introduction

What is a CadQuery?

Travis Build Status Coverage Status GitHub version License

CadQuery is an intuitive, easy-to-use python based language for building parametric 3D CAD models. CadQuery is for 3D CAD what jQuery is for javascript. Imagine selecting Faces of a 3d object the same way you select DOM objects with JQuery!

CadQuery has several goals:

  • Build models with scripts that are as close as possible to how you'd describe the object to a human.
  • Create parametric models that can be very easily customized by end users
  • Output high quality CAD formats like STEP and AMF in addition to traditional STL
  • Provide a non-proprietary, plain text model format that can be edited and executed with only a web browser

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.

Full Documentation

You can find the full cadquery documentation at http://dcowden.github.io/cadquery

Getting Started With CadQuery

The easiest way to get started with CadQuery is to Install FreeCAD (version 14+) (http://www.freecadweb.org/), and then to use our great CadQuery-FreeCAD plugin here: https://github.com/jmwright/cadquery-freecad-module

It includes the latest version of cadquery alreadby 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!

We also have a Google Group to make it easy to get help from other CadQuery users. Please join the group and introduce yourself, and we would also love to hear what you are doing with CadQuery. https://groups.google.com/forum/#!forum/cadquery

Examples

This resin mold was modeled using cadquery and then created on a CNC machine:

The cadquery script is surprisingly short, and allows easily customizing any of the variables::

import cadquery as cq
from Helpers import show
BS = cq.selectors.BoxSelector

# PARAMETERS
mount_holes = True

# mold size
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

# pocket fillet
pf = 18

# mount holes
mhd = 7  # hole diameter
mht = 3  # hole distance from edge

# filling hole
fhd = 6

# DRAWING

# draw base
base = cq.Workplane("XY").box(ml, mw, mh, (True, True, False))

# draw wire
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)))\
    .fillet(pf)

r = base.cut(pocket)

# mount holes
if mount_holes:
    px = ml/2.-mht-mhd/2.
    py = mw/2.-mht-mhd/2
    r = r.faces("<Z").workplane().pushPoints([
	(px, py),
	(-px, py),
	(-px, -py),
	(px, -py)
	]).hole(mhd)

# fill holes
r = r.faces("<Y").workplane().center(0, mh/2.).pushPoints([
    (-rl/2., 0),
    (0, 0),
    (rl/2., 0)
    ]).hole(fhd, mw/2.)

show(r)

Thanks go to cadquery contributor hyOzd ( Altu Technology ) for the example!

Why CadQuery instead of OpenSCAD?

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 libaries that exist already. So why not simply use OpenSCAD?

CadQuery scripts have several key advantages over OpenSCAD:

  1. The scripts use a standard programming language, python, and thus can benefit from the associated infrastructure. This includes many standard libraries and IDEs

  2. More powerful CAD kernel OpenCascade is much more powerful than CGAL. Features supported natively 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

  3. Ability to import/export STEP We think the ability to begin with a STEP model, created in a CAD package, and then add parametric features is key. This is possible in OpenSCAD using STL, but STL is a lossy format

  4. Less Code and easier scripting 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.

  5. Better Performance CadQuery scripts can build STL, STEP, and AMF faster than OpenSCAD.

License

CadQuery is licensed under the terms of the Apache Public License, version 2.0. A copy of the license can be found at http://www.apache.org/licenses/LICENSE-2.0

CadQuery GUI Interfaces

There are currently several known CadQuery GUIs:

CadQuery FreeCAD Module

You can use CadQuery inside of FreeCAD. There's an excellent plugin module here https://github.com/jmwright/cadquery-freecad-module

CadQuery GUI (under active development)

Work is underway on a stand-alone gui here: https://github.com/jmwright/cadquery-gui

ParametricParts.com

If you are impatient and want to see a working example with no installation, have a look at this lego brick example http://parametricparts.com/parts/vqb5dy69/.

The script that generates the model is on the 'modelscript' tab.

Installing -- FreeStanding Installation

Use these steps if you would like to write CadQuery scripts as a python API. In this case, FreeCAD is used only as a CAD kernel.

  1. install FreeCAD, version 0.15 or greater for your platform. https://github.com/FreeCAD/FreeCAD/releases.

  2. adjust your path if necessary. FreeCAD bundles a python interpreter, but you'll probably want to use your own, preferably one that has virtualenv available. To use FreeCAD from any python interpreter, just append the FreeCAD lib directory to your path. On (*Nix)::

     import sys
     sys.path.append('/usr/lib/freecad/lib')
    

    or on Windows::

     import sys
     sys.path.append('/c/apps/FreeCAD/bin')
    

    NOTE FreeCAD on Windows will not work with python 2.7-- you must use pthon 2.6.X!!!!

  3. install cadquery::

     pip install cadquery
    
  4. test your installation::

     from cadquery import *
     box = Workplane("XY").box(1,2,3)
     exporters.toString(box,'STL')
    

You're up and running!

Installing -- Using CadQuery from Inside FreeCAD

Use the Excellent CadQuery-FreeCAD plugin here: https://github.com/jmwright/cadquery-freecad-module

It includes a distribution of the latest version of cadquery.

Roadmap/Future Work

Work is underway on two other installation methods for cadquery:

  1. a conda package, which will install CQ and all of its depedencies, if you are using Anaconda
  2. a Docker image, which comes ready-to-run after you have installed docker.

Work has also begun on Cadquery 2.0, which will feature:

  1. Feature trees, for more powerful selection
  2. Direct use of OpenCascade Community Edition(OCE), so that it is no longer required to install FreeCAD
  3. https://github.com/jmwright/cadquery-gui, which will allow visualization of workplanes

Where does the name CadQuery come from?

CadQuery is inspired by jQuery, a popular framework that revolutionized web development involving javascript.

If you are familiar with how jQuery, you will probably recognize several jQuery features that CadQuery uses:

  • A fluent api to create clean, easy to read code
  • Language features that make selection and iteration incredibly easy
  • Ability to use the library along side other python libraries
  • Clear and complete documentation, with plenty of samples.

cadquery's People

Contributors

adam-urbanczyk avatar armyofevilrobots avatar bsilvereagle avatar dcowden avatar huskier avatar hyozd avatar innovationstech avatar jmwright avatar krasin avatar moeb avatar phillipthelen avatar xix-xeaon avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.