Skip to main content

An under-development 2D/3D CAD library

Project description

OpenSolid is an under-development 2D/3D CAD library. This package contains its official Python bindings. The bindings (and OpenSolid itself) are still under active development, but you’re welcome to try them out!

The package contains a single opensolid module containing a variety of classes representing geometric values and quantities, such as Length, Angle, Point2d, and Direction2d. Each class and function has a brief docstring, but here’s a brief sampling of some of the operations you can do:

>>> from opensolid import *

# Define some Length values
>>> width = Length.meters(5)
>>> height = Length.centimeters(10)

# Multiply those to get an Area value
>>> width * height
Area.square_meters(0.5)

# All values are stored in SI units internally,
# so you can mix and match units freely
>>> Length.centimeters(100) + Length.inches(10)
Length.meters(1.254)

# You can request that any length be converted into
# a value in specific units (giving back a plain 'float')
>>> Length.meters(2).in_inches()
78.74015748031496

# Define a couple of points in 2D from their
# X and Y coordinates, given in centimeters
>>> p1 = Point2d.centimeters(50, 60)
>>> p2 = Point2d.centimeters(100, 80)

# Measure the distance between the points
>>> p1.distance_to(p2)
Length.meters(0.5385164807134505)

# Build up a parametric curve (expression);
# 'Curve.t' is the curve parameter, which
# ranges from 0 to 1, so here x will range
# from 0 to 5.
>>> x = 5 * Curve.t
>>> y = x.squared() - 5 * x + 1

# Evaluate the curve at t=0.5
>>> y.evaluate(0.5)
-5.25

# Find the values of t for which y=0. For this, we need
# to set up a tolerance value. (A tolerance is needed
# for cases where e.g. the curve decreases to a tiny
# value like 1e-9 before increasing again; should that
# be considered a solution or not? Similarly, if the
# curve decreases to -1e9 and then increases again,
# should that be considered two zeros or just one? See
# the documentation of Curve.zeros for more info.)
>>> with Tolerance(1e-6):
...     # Get the location of each zero, i.e. the
...     # value of t (not x!) for which y is zero
...     roots = [zero.location() for zero in y.zeros()]
>>> roots
[0.041742430504416, 0.9582575694955838]

# Find the values of x at which y is zero,
# by evaluating x at those roots
>>> [x.evaluate(t) for t in roots]
[0.20871215252208, 4.7912878474779195]

# Check that y is in fact zero at those roots
>>> [y.evaluate(root) for root in roots]
[0.0, 0.0]

# Construct a displacement (vector with length units)
# from its components in meters
>>> d = Displacement2d.meters(1, 2)

# To get the direction of a vector, we also need to
# define a tolerance (any vector with magnitude
# smaller than this value will be considered 'zero'
# and therefore have no direction, so attempting to
# get its direction will raise an exception).
>>> with Tolerance(Length.nanometer):
...     d.direction()
Direction2d.degrees(63.434948822922)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

opensolid-0.6.0-cp312-none-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.12Windows x86-64

opensolid-0.6.0-cp312-none-manylinux_2_35_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

opensolid-0.6.0-cp312-none-macosx_14_0_arm64.whl (18.2 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

opensolid-0.6.0-cp312-none-macosx_13_0_x86_64.whl (20.3 MB view details)

Uploaded CPython 3.12macOS 13.0+ x86-64

File details

Details for the file opensolid-0.6.0-cp312-none-win_amd64.whl.

File metadata

  • Download URL: opensolid-0.6.0-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 10.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for opensolid-0.6.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 2fb0cad001b457df02af330c2f4f99677d79a92bc25a7d085a3c0af413542c09
MD5 6552c67ee2504b4f931cc47cad3684b1
BLAKE2b-256 c89133e0ac113cea6304f0a521a52378f607c69d3d5d1a62489ecb3ba90c351e

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensolid-0.6.0-cp312-none-win_amd64.whl:

Publisher: main.yml on ianmackenzie/opensolid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opensolid-0.6.0-cp312-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for opensolid-0.6.0-cp312-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 570ca5cdd894173b328113ae079ca163227dc042e8200c421f09e467c39869af
MD5 a14e9ae2265f949a6a486ad9b6be879e
BLAKE2b-256 f9acc437c9b21afad21736bdad77e2bf2e899707ef14913f7a42a42c6c74653f

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensolid-0.6.0-cp312-none-manylinux_2_35_x86_64.whl:

Publisher: main.yml on ianmackenzie/opensolid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opensolid-0.6.0-cp312-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for opensolid-0.6.0-cp312-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9e86f00adae4d203bc734d24484b87794d76eae1498c7f7c78f445188c8bbd84
MD5 9c9c9e9c7d7e8d271f1ab65c06a5e1a2
BLAKE2b-256 57b586f71aa28f2b0ef8fd3b1a8c3adafd208b267bd10c89b4c39d97e579e2f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensolid-0.6.0-cp312-none-macosx_14_0_arm64.whl:

Publisher: main.yml on ianmackenzie/opensolid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opensolid-0.6.0-cp312-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for opensolid-0.6.0-cp312-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 ac164c2cb3ec583b021e62efcb9c0dd25afdd43d3ac6e7c778f5d7e361066a4e
MD5 4c5b0b3f3f97a5ea7ec2c150781fb4d1
BLAKE2b-256 c7aac310c58c9306bde090b6ddd2c2dbaca5ef86c73eb0f9dca828aed5298974

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensolid-0.6.0-cp312-none-macosx_13_0_x86_64.whl:

Publisher: main.yml on ianmackenzie/opensolid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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