CAD primitives to produce images and drawings in a variety of formats from a common symbolic definition.
Project description
cadlib
CAD primitives to produce images and drawings in a variety of formats from a common symbolic definition.
cadlib is a 2D CAD geometry library written in Python. It models manual drafting workflows: constructing geometry by creating points, lines, circles, and arcs, then using transformations (mirror, rotate) to build complex shapes.
Installation
pip install cadlib
Quick Start
import cadlib
# Create geometry
center = cadlib.Point(0, 0)
circle = cadlib.Circle(center, 10)
line = cadlib.Line(cadlib.Point(-15, 5), cadlib.Point(15, 5))
# Find intersections
pt = circle.point_at_line_intersection(line, q=1)
# Use transformations
mirrored = line.mirror_x(0)
rotated = line.rotate(center, 45)
Sprocket Generation
cadlib includes a sprocket generator implementing ANSI standard sprocket geometry per the gearseds design specification.
# Generate SVG
cadlib-sprocket svg
# Display with matplotlib
cadlib-sprocket matplotlib
Or use it programmatically:
from cadlib.sprocket import Sprocket, create_svg, create_matplotlib
sprocket = Sprocket(ansi_chain_type="25", n_number_of_teeth=8)
create_svg(sprocket)
Core API
Primitives
Point(x, y)-- 2D point with mirror and rotate transformationsLine(p1, p2)-- line segment between two pointsCircle(center, radius)-- circle with intersection and tangency methodsArc(center, radius, angle1, angle2)-- arc defined by center, radius, and angle range
Factory Functions
arc_from_points_and_radius(p1, p2, r, q)-- arc from two points and radiusarc_from_points_and_center(p1, p2, center)-- arc from two points and centerarc_from_points_and_radius_and_height(p1, p2, height)-- arc from chord and heightline_from_pt_angle_len(point, angle, length)-- line from point, angle, length
Layers and Drawing
Layer-- groups elements for rendering controlDrawing-- collection of elements with coordinate transforms for outputLAYER_CONSTRUCTION-- default layer for construction guides (gray)LAYER_TOOLPATH-- layer for cutting/tool paths (red)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cadlib-0.1.0.tar.gz.
File metadata
- Download URL: cadlib-0.1.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7842d2566fc7537f117989fcf3f5ddb188e5256a6745aa4e58830a6f249054bc
|
|
| MD5 |
8905d2ce6b876eedce482f4e84888439
|
|
| BLAKE2b-256 |
a580d7b20a1873b68cd920b60bbc7f5a196dc267ec7b667ff96c5ebfd888d9ef
|
File details
Details for the file cadlib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cadlib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24099f10aa8b663c1f9cd0fcde48a90c8843366cd269b492a362d2103f5ae6b
|
|
| MD5 |
afe73fb3280aa8ca02e7e3bc63f72509
|
|
| BLAKE2b-256 |
12f42a2cc307bc176c1439c0c12279d88c9bc74e59eba5932b486bea22dbf4a6
|