Metadata-Version: 2.1
Name: bd_shape_history
Version: 0.1.1
Summary: A tool to manage and visualize the modification history of Build123D objects.
Home-page: https://codeberg.org/roipoussiere/bd_shape_history
License: MIT
Keywords: cad,build123d,history
Author: Nathanaël Jourdane
Author-email: njourdane@protonmail.com
Requires-Python: >=3.11,<3.13
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Manufacturing
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Debuggers
Requires-Dist: cadquery-ocp (>=7.7.2,<8.0.0)
Requires-Dist: ocp-tessellate (>=3.0.8,<4.0.0)
Requires-Dist: ocp-vscode (>=2.6.1,<3.0.0)
Project-URL: Repository, https://codeberg.org/roipoussiere/bd_shape_history
Description-Content-Type: text/markdown

# Build132d Shape History

A tool to manage and visualize the modification history of Build123D objects.

## Installation

This package is [published on Pypi](https://pypi.org/project/bd_shape_history/):

```
pip install bd_shape_history
```

## Usage

Assuming a simple part created in 3 steps:

```py
box = _.Box(3, 3, 1)
cbox = _.chamfer(box.edges()[0], 0.5)
cboxh = cbox - _.Cylinder(0.75, 1)
```

We can build the history with:

```py
hm = ShapeHistory.from_globals()
```

And then display it `diff()` (here with [VScode OCP CAD viewer](https://github.com/bernhard-42/vscode-ocp-cad-viewer/)):

```py
ov.set_defaults(render_edges=False)
ov.show(*hm.diff(), names=hm.labels())
```

This shows a visual diff between each step:

![](./docs/images/step1.png) ![](./docs/images/step2.png) ![](./docs/images/step3.png)

Notice how the object is colored:
- new faces and edges are green and light green;
- unchanged faces and edges are gray and black;
- modified faces and edges are dark green and olive

See the `examples` folder for more details.

## Command line interface

You can compare two files and export the diff as an image using the `ocp_diff` script. For instance:

    ocp_diff ./examples/a.py:box ./examples/b.py:box img.png

## How does it work

ShapeHistory compares the hash of faces, edges and vertices between each steps:

- a face or edge whose hash is found on the previous step is considered unmodified;
- a face whose all edges are not found in the previous step is considered added (and same for edge / vertices);
- otherwise the face or edge is considered modified.

