Amazing CAD in haskell that compiles to OPENSCAD, by yours truly (Jasen Qin)
Unicode Glyph Functions
This library provides Unicode glyph aliases for CAD operations. Here's the complete mapping:
3D Shapes
■(U+25A0) -cube- Creates a cube/rectangular prism●(U+25CF) -sphere- Creates a sphere◎(U+25CE) -cylinder- Creates a cylinder▻(U+25BB) -cone- Creates a cone▬(U+25AC) -rect- Creates a rectangle (alias for cube)⎏(U+23CF) -prism- Creates a regular prism
2D Shapes
△(U+25B3) - Equilateral triangle profile⬠(U+2B20) - Regular pentagon profile⭘(U+2B58) - Circle profile⟁(U+27C1) -poly- Creates a polygon with points and paths
Transformations
χ(U+03C7) -Tx- Translation along X-axisψ(U+03C8) -Ty- Translation along Y-axisζ(U+03B6) -Tz- Translation along Z-axisθ(U+03B8) -Rx- Rotation around X-axisϕ(U+03C6) -Ry- Rotation around Y-axisω(U+03C9) -Rz- Rotation around Z-axis⬈(U+2B08) -Scale- Scaling transformation⮕(U+2B95) -Extrude- Linear extrusion (2D → 3D)
Boolean Operations
⊖(U+2296) -Diff- Boolean difference⊝(U+229D) -Diff- Boolean difference (alias)⊛(U+229B) -Union- Boolean union (alias)⊕(U+2295) -Union- Boolean union
Advanced Operations
⇓(U+21D3) -Hull- Convex hull operation⊞(U+229E) -Minkowski- Minkowski sum operation↯(U+21AF) -Offset- Offset operation (2D profiles)
Composition Operations
|>(U+007C U+003E) - Forward pipe operator▷(U+25B7) - Forward pipe operator (alias)
CLI Usage
The coscad CLI tool converts .coscad files to .scad (OpenSCAD) format.
Basic Usage
coscad <input.coscad>This will create a corresponding .scad file in the same directory.
Examples
Create a simple cube:
echo "■ 10" > cube.coscad
coscad cube.coscadCreate a sphere:
echo "● 15" > sphere.coscad
coscad sphere.coscadCreate a cylinder:
echo "◎ 5 10" > cylinder.coscad
coscad cylinder.coscadCreate a cone:
echo "▻ 8 15" > cone.coscad
coscad cone.coscadBoolean operations:
echo "● 15 ⊖ ◎ 5 10" > difference.coscad
coscad difference.coscadecho "■ 10 ⊕ ● 5" > union.coscad
coscad union.coscadAdvanced operations:
echo "■ 10 ⇓ ● 5" > hull.coscad
coscad hull.coscadecho "■ 10 ⊞ ● 5" > minkowski.coscad
coscad minkowski.coscadecho "△ 8 ↯ ● 2" > offset.coscad
coscad offset.coscadSyntax
The current parser supports:
- Basic shapes:
■ size,● radius,◎ radius height,▻ radius height - Boolean operations:
shape1 ⊖ shape2(difference),shape1 ⊕ shape2(union) - Advanced operations:
shape1 ⇓ shape2(hull),shape1 ⊞ shape2(minkowski),profile ↯ shape(offset)
Building
To build the project:
stack buildThis creates the executable in .stack-work. You can add its path to PATH to call coscad directly.
Otherwise, to run the executable with stack:
stack run -- input.coscad