Skip to main content

This Python program provides a simple, fast, and robust way to visually compare 3d files such as STL, OBJ, 3MF, and STEP. The unchanged parts of the objects are shown in gray, while the changed parts are shown in contrasting colors that stand out, illustrated by the following example.

In this example most of the lens clamp is unchanged and is displayed in gray, while the differing parts are displayed in red for one file and green for the other file: in the red file the diameter is smaller, while in the green file the base is longer, and the threaded hole has moved.

Quick start

You will need to have Python installed - see notes in the next section on installing Python if you don't already have it. Python comes with a program called pip for installing Python programs at the system level. To install diff3d run this command:

pip install diff3d

(On some Linux systems you may need to use pipx instead of pip; see next section.)

Then to test the installation download two test files lens-clamp-A.stla and lens-clamp-B.stl and run the command

diff3d lens-clamp-A.stl lens-clamp-B.stl

The first time you run the diff3d command it may take a little time to start while it loads and compiles the supporting packages, but after that the startup time will be very quick.

You can drag the displayed object to rotate it, use the mouse wheel to zoom, and shift-drag to pan.

The second file is optional, in which case the first file will simply be displayed without diffs. This allows the tool to be used as a simple 3d file viewer in addition to its primary function.

Supported platforms, file formats, and object types

I have tested on the following platforms:

  • Windows 11, Python 3.13. Download and install from python.org, and in the installation program be sure to check the the box that says "Add python.exe to PATH" which will make pip and diff3d available from the command line. Then open a command prompt window and type pip install diff3d.

  • MacOS, Python 3.13 installed using brew install python, then pip install diff3d.

  • Linux Mint, Python 3.13 installed using sudo apt install python pipx, then pipx install diff3d (instead of using pip).

Out of the box diff3d supports STL, OBJ, and 3MF files. Support for a number of additional file types is available by installing meshio, and support for STEP files can be enabled by installing build123d.

Unlike other tools that do 3d diffs by using 3d boolean operations like intersection and difference, this tool is robust and is not limited to manifold (closed surface) meshes, but can diff anything that can be rendered, including open surfaces, curves, and points.

Color animation

Small areas of difference may be difficult to spot under some circumstances, especially for people with some form of colorblindness. To help highlight areas of difference, you can press the "a" key and the colored areas will flash briefly.

This feature was inspired by the much more sophisticated color animations for enhancing color vision provided by ColorPhi.

Object alignment

In some cases two objects to be compared may be shifted relative to each other in addition to other changes. This is illustrated by example files lens-clamp-A.obj and lens-clamp-C.obj in the images below.

The first image is produced by just comparing the two files as-is without any attempt to align them:

diff3d lens-clamp-A.obj lens-clamp-C.obj

The misalignment obscures the relevant changes.

The second image was produced by aligning the centroids of the two objects. This is better, but it is still difficult to see the interesting changes.

Instead diff3d provides an alignment method that attempts to align the objects such that major features that they have in common are aligned, thus displaying a minimal set of differences between the objects. This is illustrated by the third image above, produced using the --align flag:

diff3d --align lens-clamp-A.obj lens-clamp-C.obj

This is not the default because it's not always necessary and it may take a bit of time to do the alignment. The first time you use the --align option it may take a little time to start while it loads and compiles the supporting packages, but after that the startup time will be very quick.

Color schemes

Three color schemes designed to be colorblind-friendly are provided. (This is based on information from https://davidmathlogic.com/colorblind, and I have not verified this. If you have information to add please contact me by opening an issue on github.)

You can choose a scheme using the -s or --scheme option. The above schemes are named "1", "2", and "3" respectively.

API

The diff3d module provides a simple API if you want to integrate it into your own program. As this is an early version of the program, I'll try to maintain the stability of these APIs, but I can't guarantee it. See the code for details.

  • diff3d.from_files opens a window displaying the diff between two files

  • diff3d.diff opens a window displaying the diff between two pyvista objects.

  • If you are using a different mesh or CAD package, if you can obtain point and triangle arrays, you can convert them to pyvista objects using pyvista.PolyData.from_regular_faces

  • You can align two meshes without displaying them using diff3d.align3d.

Discussions and Issues

If you would like to report an issue, ask a question, or make a suggestion you do so through the Discussions and Issues pages.

Metadata

Release files for diff3d 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diff3d 0.3.0
File Size Uploaded Provenance Actions
diff3d-0.3.0.tar.gz 2.9 MB Without provenance Details for diff3d-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for diff3d 0.3.0
File Interpreter ABI Platform Actions
diff3d-0.3.0-py3-none-any.whl Python 3 none any Details for diff3d-0.3.0-py3-none-any.whl

Total release size: 2.9 MB

Release files / diff3d-0.3.0.tar.gz

Download URL diff3d-0.3.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
39ad369be351ee2905f153a00b0f2955c99017565e3e10e70db73278fcc4ccc3
BLAKE2b-256 checksum
How to use checksums
315460ef69de68f8d371d704a1384fb93d61004169ce55dcb1302e51f90951b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release files / diff3d-0.3.0-py3-none-any.whl

Download URL diff3d-0.3.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28884015e6cf724f72334371b18fb1e7ea85e3167f85c11a3bb2ba5e4b8d44d8
BLAKE2b-256 checksum
How to use checksums
36096997bc53a016be1895b4537795593368b6166a7ad623afa4f7549ee539a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Security for diff3d 0.3.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page