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.

Source Distribution

petrify-0.8.1.tar.gz (48.3 kB view details)

Uploaded Source

File details

Details for the file petrify-0.8.1.tar.gz.

File metadata

  • Download URL: petrify-0.8.1.tar.gz
  • Upload date:
  • Size: 48.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for petrify-0.8.1.tar.gz
Algorithm Hash digest
SHA256 97650d496314ad0fe5bbc0af78abadda76b3511951f5546892282dd0df9b583b
MD5 c388d6b6ae453703876baf8568dc7788
BLAKE2b-256 c14c2590df9e4f051cc151e1783f84336422aa6c210c192675c39df2cde4c5df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page