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:
pycsg
pyeuclid v3 fork (https://github.com/ezag/pyeuclid/)
the reverbat STL PR on pycsg (https://github.com/timknip/pycsg/pull/9)
Metadata
Release files for petrify 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| petrify-0.8.1.tar.gz | 48.3 kB | Without provenance | Details |
Release files / petrify-0.8.1.tar.gz
| Download URL | petrify-0.8.1.tar.gz |
|---|---|
| Size | 48.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97650d496314ad0fe5bbc0af78abadda76b3511951f5546892282dd0df9b583b
|
|
BLAKE2b-256 checksum How to use checksums |
c14c2590df9e4f051cc151e1783f84336422aa6c210c192675c39df2cde4c5df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for petrify 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.