Metadata-Version: 2.2
Name: planegcs
Version: 0.1.2
Summary: Python bindings for FreeCAD's PlaneGCS 2D geometric constraint solver
Author: planegcs contributors
License: LGPL-2.1-or-later
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Project-URL: Homepage, https://github.com/spookylukey/planegcs
Project-URL: Documentation, https://planegcs.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/spookylukey/planegcs
Project-URL: Tracker, https://github.com/spookylukey/planegcs/issues
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# planegcs

Python bindings for FreeCAD's PlaneGCS 2D geometric constraint solver.

This project extracts the constraint solver system from
[FreeCAD](https://www.freecad.org/)'s
[Sketcher](https://wiki.freecad.org/Sketcher_Workbench) component, changes the
headers so that it can be used outside FreeCAD, and adds some thin C++ and
Python wrappers so it can be used as a Python library. As per the [FreeCAD
licence requirements](https://wiki.freecad.org/License), the result is licenced
under the LPGL 2.1 or later.

## Installation

```bash
pip install planegcs
```

or:
```bash
uv add planegcs
```

If wheels aren't available, you'll need C++ tools and some development headers:

- eigen3
- boost

## Quick Start

```python
from planegcs import Sketch, SolveStatus

s = Sketch()

# Create three points for a triangle
p1 = s.add_point(0, 0)
p2 = s.add_point(5, 0)
p3 = s.add_point(2.5, 4)

# Create lines
l1 = s.add_line(p1, p2)
l2 = s.add_line(p2, p3)
l3 = s.add_line(p3, p1)

# Make it equilateral
s.equal_length(l1, l2)
s.equal_length(l2, l3)

# Fix first point and make base horizontal
s.fix_point(p1, 0, 0)
s.horizontal(l1)

# Fix the side length to 5
d = s.add_param(5.0)
s.p2p_distance(p1, p2, d)

# Solve
status = s.solve()
assert status == SolveStatus.Success

# Read results
print(s.get_point(p1))  # (0.0, 0.0)
print(s.get_point(p2))  # (5.0, 0.0)
print(s.get_point(p3))  # (~2.5, ~4.33)
```

## Docs

Full documentation at [readthedocs](https://planegcs.readthedocs.io/en/latest/),
and in the `docs/` folder (requires Sphinx to build).

## License

LGPL-2.1-or-later (same as the FreeCAD source code it wraps).
