- Allows fine-grained control over the number of samples for Bezier curves and arcs
- Capability to output the results into a JSON file or a SCAD file wrapped into a polygon module.
- Scaling, flipping, rotating, moving capabilities.
- Display graph to visualize the generated result
- Output final result dimensions
python svg_to_scad.py --input demo/straight_lines.svg --output demo/straight_lines.json
Width: 60.292721 Height: 83.38827 Coordinates saved to demo/straight_lines.json
Graph:
python svg_to_scad.py -i demo/straight_lines.svg -o demo/straight_lines.json --close
Width: 60.292721 Height: 83.38827 Coordinates saved to demo/straight_lines.json
Graph:
python svg_to_scad.py -i demo/bezier_curves.svg -o demo/bezier_curves.scad --number-samples 10
Width: 141.81590968696838 Height: 99.41870528120708 Coordinates saved to demo/bezier_curves.scad
Graph:
python svg_to_scad.py -i demo/bezier_curves.svg -o demo/bezier_curves.scad -n 15 --center-of-gravity
Width: 141.8418028987973 Height: 99.69069757835271 Coordinates saved to demo/bezier_curves.scad
Graph:
For a complete list of options, consult the help menu:
python svg_to_scad.py --help
usage: svg_to_scad.py [-h] -i INPUT [-n NUMBER_SAMPLES] [-o OUTPUT] [-c] [-f {x,y}] [-s SCALE] [-r ROTATE] [-g] [-C] Convert SVG paths to a list of coordinates for use in OpenSCAD. options: -h, --help show this help message and exit -i, --input INPUT Path to the SVG file. -n, --number-samples NUMBER_SAMPLES Number of samples for Bezier curves and arcs (default: 100). -o, --output OUTPUT Output file name (default: coordinates.scad). -c, --close Close the path by adding the first point to the end if not already closed. -f, --flip {x,y} Flip the coordinates either horizontally or vertically. -s, --scale SCALE Scale the coordinates. Format: x:y, x:, or :y -r, --rotate ROTATE Rotate the coordinates by the specified angle (in degrees). -g, --center-of-gravity Center the coordinates at the center of gravity of the shape. -C, --center Center the shape at the origin based on the bounding rectangle.
// Load the generated SCAD files
use <straight_lines.scad>
use <bezier_curves.scad>
// Use the polygon modules defined in the included files
translate([-200, -40, 0]) {
linear_extrude(10)
straight_lines();
}
translate([-100, -100, 0]) {
linear_extrude(15)
bezier_curves();
}