Skip to main content

a programmatic cad library

Project description

Petrify Logo https://travis-ci.org/AnIrishDuck/petrify.svg?branch=master Documentation Status https://mybinder.org/badge_logo.svg

A library for constructing, importing, visualizing, modifying, and exporting three-dimensional geometry and toolpaths. Designed for CAD / CAM applications.

To get started with this library, we recommend walking through the demos below. Each notebook contains links to our comprehensive class and method-level documentation.

Online Demo

Thanks to the magic of binder, you can try out petrify online. We have demos for several core petrify features:

  • Construction of many basic solids.
  • Methods for defining advanced solids.
  • Combining multiple solids into a single complex solid.
  • Setting visual properties on solids to create the above logo.

Have patience; notebooks on binder can take up to a minute to start. Due to a (possible) bug in pythreejs, you’ll need to click “restart and run all” to see the relevant interactive visualizations.

Design Principles

  • Novice focus. This library should make it as easy as possible to build and manipulate solids, shapes, and other geometry.
  • Immutable operation. Immutable math is easier for most audiences to reason about. This library explicitly does not target strong real-time applications like games that demand mutability for performance.
  • Pluggable engines. CSG is complicated. Different engines have different tradeoffs:
    • The pymesh engine is the default where the pymesh2 library is installed. It uses the CGAL CSG engine, which is mature and quite fast. However, building pymesh with CGAL support can be difficult for novices and in certain environments (like Windows and OSX).
    • cython-csg is relatively fast, but still requires a cython build toolchain.
    • pycsg is a pure-python implementation. It is obviously quite slow, but works everywhere python does. For example, pure python environments like pyiodide can utilize this engine easily.

Quickstart with Docker

We recommend using petrify inside our prepackaged docker image. This image has all the necessary libraries for running a Jupyter notebook server, and the pymesh engine already installed:

docker run -it -p 8888:8888 \
  -v $(pwd)/notebooks:/home/jovyan/work \
  anirishduck/petrify

The above command will expose a notebook on port 8888 with the necessary volume mounts for persisting the work directory. The server will output a ?token=<xxxxx> query parameter you will need for authentication.

Installation

petrify is published online via pip:

pip install petrify

We strongly recommend using its visualization capabilities in combination with Jupyter:

pip install notebook pythreejs

While petrify is functional from this point, you almost certainly want to install a more powerful engine than the default pycsg one. See our csg example for more detail on why; read on to learn how.

pymesh2

pymesh is the most mature driver, but also has the most complicated installation procedure. We currently only recommend this installation in a Linux-like environment. You can also use WSL if on Windows, or a VM on OSX.

You will need to build pymesh with CGAL support to use this engine. To install in Ubuntu or Debian environments:

sudo apt-get install libcgal-dev

Now, you can install using the normal PyMesh installation procedure. In Linux-like environments, you can probably just install all the needed library dependencies in the documentation, and then run:

pip install pymesh2

cython-csg

Installation of cython-csg requires a working build of cython, which should be available on most major platforms:

pip install cython

From here, the installation of cython-csg should be entirely automated:

pip install cython-csg

Contributors

This library is a fusion of:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for petrify, version 0.8.1
Filename, size File type Python version Upload date Hashes
Filename, size petrify-0.8.1.tar.gz (48.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page