A python CAD programming library
Find a file
Aleksi Torhamo acbebfb017 Fix __eq__ and __ne__ for classes implementing them
Main issue, which concerns Vector, Location, and ShapeList:

Comparison with an object of a different type should not cause an
exception - they are simply not equal. Raising an exception in __eq__
can (and will*) break unrelated code that expects __eq__ to be well-behaved.

(* I noticed this bug when cq-editor choked on it while trying to find
   a name for an object in a dictionary of local variables)

There's a second more minor issue, which concerns the rest of the classes:

When the other type in __eq__ is not supported, one should technically
return NotImplemented instead of False, to allow the other type to take
part in the comparison, in case they know about our type.

(__ne__ should also not generally be implemented as just the negation of
__eq__ because of this, but that's also a moot point because the __ne__
can just be removed - Python will automatically do the right thing based
on __eq__ here)

Technically, the __eq__ for Vector and Plane is also broken in another way:
It's not transitive.

>>> a, b, c = Vector(0), Vector(9e-6), Vector(18e-6)
>>> a == b == c
True
>>> a == c
False

They should really eg. have a separate is_close() for approximate comparison,
but this isn't fixed here, since I have no idea how many places it'd break,
for one.
2024-09-22 08:07:00 +03:00
.github test.yml -> undo temporary change for debugging 2024-08-29 16:05:21 -05:00
docs Merge pull request #667 from jdegenstein/docfixes 2024-09-09 10:35:54 -05:00
examples heat_exchanger_algebra.py -> Fix example to use radius instead of apothem 2024-06-19 20:34:00 -05:00
src/build123d Fix __eq__ and __ne__ for classes implementing them 2024-09-22 08:07:00 +03:00
tests Fix __eq__ and __ne__ for classes implementing them 2024-09-22 08:07:00 +03:00
.gitignore Speed up test_pack.py by fuse()ing once per test case. 2023-11-15 11:03:21 -08:00
.pylintrc Resolve all pylint in {im,ex}porters.py 2023-11-14 19:45:38 -08:00
.readthedocs.yaml Update .readthedocs.yaml to ubuntu-22.04 2023-09-28 11:29:16 -05:00
CONTRIBUTING.md CONTRIBUTING.md -> standardize on black formatter 2024-02-22 10:33:39 -06:00
LICENSE Adding LICENSE file 2023-08-20 14:43:46 -04:00
MANIFEST.in scm_versioning MANIFEST.in and pyproject.toml 2023-02-21 21:00:25 -06:00
mypy.ini mypy static typechecking improvements 2023-02-20 18:35:27 -05:00
partcad.yaml Unregistered the removed example from the PartCAD package 2024-04-14 17:06:22 -07:00
pyproject.toml Update pyproject.toml 2024-06-24 21:29:51 -05:00
README.md Updating docs for pypi installation 2023-12-06 14:43:41 -05:00
requirements.txt Adding coverage badge 2023-02-13 20:41:01 -05:00

build123d logo

Documentation Status tests pylint codecov

Build123d is a python-based, parametric, boundary representation (BREP) modeling framework for 2D and 3D CAD. It's built on the Open Cascade geometric kernel and allows for the creation of complex models using a simple and intuitive python syntax. Build123d can be used to create models for 3D printing, CNC machining, laser cutting, and other manufacturing processes. Models can be exported to a wide variety of popular CAD tools such as FreeCAD and SolidWorks.

Build123d could be considered as an evolution of CadQuery where the somewhat restrictive Fluent API (method chaining) is replaced with stateful context managers - e.g. with blocks - thus enabling the full python toolbox: for loops, references to objects, object sorting and filtering, etc.

The documentation for build123d can found at readthedocs.

There is a Discord server (shared with CadQuery) where you can ask for help in the build123d channel.

The recommended method for most users is to install build123d is:

pip install build123d

To get the latest non-released version of build123d* one can install from GitHub using one of the following two commands:

In Linux/MacOS, use the following command:

python3 -m pip install git+https://github.com/gumyr/build123d

In Windows, use the following command:

python -m pip install git+https://github.com/gumyr/build123d

If you receive errors about conflicting dependencies, you can retry the installation after having upgraded pip to the latest version with the following command:

python3 -m pip install --upgrade pip

Development install

git clone https://github.com/gumyr/build123d.git
cd build123d
python3 -m pip install -e .

Further installation instructions are available (e.g. Poetry, Apple Silicon) see the installation section on readthedocs.