SLVSX Constraint Solver Examples
A collection of examples demonstrating the SLVSX constraint solver for parametric design and mechanical systems.
View Interactive 3D Examples
SLVSX is a command-line interface to the SolveSpace constraint solver. It allows you to define geometric relationships declaratively and have the solver calculate actual positions automatically.
Example
Description
Preview
Gear Mechanism
Two meshing gears with proper tooth spacing
SVG
Example
Description
Preview
Bezier Path
Cubic Bezier S-curve with perpendicular control handles
SVG
Tangent Arc Chain
Arc-to-line tangent constraint for smooth transitions
SVG
Example
Description
Preview
Symmetric Bracket
Bracket with notch and mounting holes, demonstrating symmetry via parallel constraints
SVG
Parametric Hinge
3D-printable hinge joint with configurable dimensions
SVG
New Constraint Demos (v0.2.8)
Example
Description
Preview
Collinear Demo
Points constrained to a single line using new collinear constraint
SVG
Equal Angles Demo
Radial spokes with equal angular spacing using new equal_angles constraint
SVG
Example
Description
Basic Shapes
Triangle, square, hexagon, pentagon - for learning constraint basics
Examples showing the same design solved at different parameter values:
Example
Description
Preview
Four-Bar Animation
Same linkage at 6 crank angles (0°, 60°, 120°, 180°, 240°, 300°)
SVG
Prime Stars
Radial patterns with 3, 5, 7, 11, 13 points using equal_angles
SVG
# Install SLVSX
curl -fsSL https://raw.githubusercontent.com/snoble/slvsx-cli/main/install.sh | bash
# Clone examples
git clone https://github.com/snoble/slvx-examples.git
cd slvx-examples
# Solve a linkage
slvsx solve four_bar_linkage/four_bar_linkage.json
# Export to SVG
slvsx export -f svg four_bar_linkage/four_bar_linkage.json > output.svg
open output.svg
Creating Your Own Examples
Read the Visual Design Guide before creating examples.
Build incrementally - Add entities one at a time, test after each
Export to SVG - Visually inspect at every step
Use parameters - Make key dimensions parametric
Provide good initial guesses - Use at fields for points
{
"schema" : " slvs-json/1" ,
"units" : " mm" ,
"parameters" : {
"link_length" : 50 ,
"angle" : 30
},
"entities" : [
{"type" : " point" , "id" : " origin" , "at" : [0 , 0 , 0 ]},
{"type" : " line" , "id" : " link" , "p1" : " origin" , "p2" : " end" }
],
"constraints" : [
{"type" : " fixed" , "entity" : " origin" },
{"type" : " distance" , "between" : [" origin" , " end" ], "value" : " $link_length" }
]
}
Constraint
Purpose
Example Use
fixed
Anchor a point
Origin, pivot points
distance
Set distance between points
Lengths, radii
angle
Set angle between lines
Rotations, slopes
perpendicular
Make lines 90 degrees
Right angles
parallel
Make lines parallel
Rails, guides
point_on_line
Point lies on line
Sliders, intersections
equal_length
Make segments equal
Regular polygons
midpoint
Point at midpoint
Centering
point_on_circle
Point lies on circle
Wheels, orbits
diameter
Set circle diameter
Sizing circles
tangent
Make arc/line tangent
Smooth transitions
collinear
3+ points on same line
Rail alignment (v0.2.8+)
equal_angles
Equal angles between lines
Radial patterns (v0.2.8+)
See GitHub Issues for current bugs and feature requests.
Fixed in v0.2.8:
equal_length with >2 entities - FIXED! No longer crashes
point_on_line fails with 2D entities - FIXED in PR #50
Still Open:
symmetric_vertical/symmetric_horizontal collapse points (issue #49) - use parallel + fixed as workaround
Arc and cubic Bezier entities don't render in SVG export (issue #51) - entities solve correctly but SVG output doesn't show curves
rube_goldberg_machine example fails with "Invalid solver system" (issue #52)
Circles don't track points - use points for moving parts
Examples are provided as-is for educational purposes.