Skip to main content

Python library of Solvespace.

Project description

PyPI GitHub license

python-solvespace

Python library from the solver of SolveSpace, an open source CAD software.

The example extracted from unit test:

from python_solvespace import SolverSystem, ResultFlag

sys = SolverSystem()
wp = sys.create_2d_base()  # Workplane (Entity)
p0 = sys.add_point_2d(0, 0, wp)  # Entity
sys.dragged(p0, wp)  # Make a constraint with the entity
...
line0 = sys.add_line_2d(p0, p1, wp)  # Create entity with others
...
line1 = sys.add_line_2d(p0, p3, wp)
sys.angle(line0, line1, 45, wp)  # Constrain two entities
line1 = sys.entity(-1)  # Entity handle can be re-generated and negatively indexed
...
if sys.solve() == ResultFlag.OKAY:
   # Get the result (unpack from the entity or parameters)
   # x and y are actually float type
   dof = sys.dof()
   x, y = sys.params(p2.params)
   ...
else:
   # Error!
   # Get the list of all constraints
   failures = sys.failures()
   ...

Solver can also be serialized and copied, but can not modify or undo last step.

import pickle
print(pickle.dumps(sys))

sys_new = sys.copy()

The entity and parameter handles should have the same lifetime to the solver.

Install

pip install python-solvespace

Build and Test (Repository)

First build and install the module from the repo:

git submodule update --init extlib/mimalloc extlib/eigen
cd cython
pip install -e .

Rebuild the module:

pip install -e . --no-deps

Run the unit tests:

python -m unittest

Uninstall the module:

pip uninstall python-solvespace

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_solvespace-3.0.7.tar.gz (1.2 MB view hashes)

Uploaded Source

Built Distributions

python_solvespace-3.0.7-cp310-cp310-win_amd64.whl (244.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

python_solvespace-3.0.7-cp310-cp310-macosx_10_15_x86_64.whl (383.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

python_solvespace-3.0.7-cp39-cp39-win_amd64.whl (243.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

python_solvespace-3.0.7-cp39-cp39-macosx_10_15_x86_64.whl (383.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

python_solvespace-3.0.7-cp38-cp38-win_amd64.whl (245.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

python_solvespace-3.0.7-cp38-cp38-macosx_10_14_x86_64.whl (380.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

python_solvespace-3.0.7-cp37-cp37m-win_amd64.whl (238.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

python_solvespace-3.0.7-cp37-cp37m-macosx_10_15_x86_64.whl (376.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

python_solvespace-3.0.7-cp36-cp36m-win_amd64.whl (250.0 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

python_solvespace-3.0.7-cp36-cp36m-macosx_10_14_x86_64.whl (382.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page