Skip to content
/ cqparts Public
forked from cqparts/cqparts

Parts collection for model creation with `cadquery`, and a basis for other parts libraries.

License

Notifications You must be signed in to change notification settings

zignig/cqparts

 
 

Repository files navigation

image

What is cqparts?

cqparts is CAD for Python programmers, short for "cadquery parts".

Using cqparts you can wrap geometry made with cadquery to build complex and deeply parametric models.

Full documentation at: https://cqparts.github.io/cqparts

Installing

Pre-requisites

You'll need to fulfill the requirements of cadquery, the simplest way to do that is to install cadquery first by following the instructions here:

http://dcowden.github.io/cadquery/installation.html

PyPI

Once cadquery is installed, install cqparts with:

pip install cqparts

cqparts_* Content Libraries

You can also install content libraries with a similar pip install command.

List available libraries with:

pip search cqparts-

For example, to install the cqparts_bearings content library, run:

pip install cqparts-bearings

_Note: pip packages use - to separate words, but when importing them the standard _ is used.

Example Usage

Here is just one of the simplest examples to give you an idea of what this library does.

More detailed examples found in the official documentation for cqparts.

Wrapping a Cube

image

A simple cube defined with cadquery alone:

# create unit cube solid
import cadquery
size = 10
cube = cadquery.Workplane('XY').box(size, size, size)

# display cube (optional)
from Helpers import show
show(cube)

Wrapping this in a cqparts.Part object can be done like this:

# create unit cube as cqparts.Part
import cadquery
import cqparts
from cqparts.params import PositiveFloat

class MyCube(cqparts.Part):
    size = PositiveFloat(1, doc="cube size")
    def make(self):
        return cadquery.Workplane('XY').box(self.size, self.size, self.size)

# create cube instance
cube = MyCube(size=10)

# display cube (optional)
from cqparts.display import display
display(cube)

You can see that under the bonnet (in the make function) the geometry is created with cadquery, but the resulting MyCube class is instantiated more intuitively, and more object orientated.

Creating a Hierarchy

cqparts can also be used to create a deep hierarchy of parts and assemblies to build something deeply complicated and entirely parametric.

A simple example of this is the toy car tutorial.

image

cqparts Capabilities

The work done in cqparts_fasteners is a good example of how useful cqparts wrapping can be; read about the Fastener class, how it works, and what can be done with it in the cqparts_fasteners docs

image

Contributing

Issues, and Pull Requests are encouraged, and happily received, please read CONTRIBUTING.md for guidance on how to contribute.

About

Parts collection for model creation with `cadquery`, and a basis for other parts libraries.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 79.8%
  • JavaScript 13.9%
  • HTML 4.4%
  • Shell 1.7%
  • Other 0.2%