Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active July 4, 2025 09:47
Show Gist options
  • Save ochafik/95587ff653ecb708cbf9a735723b1478 to your computer and use it in GitHub Desktop.
Save ochafik/95587ff653ecb708cbf9a735723b1478 to your computer and use it in GitHub Desktop.
OpenSCAD launch script to get blazingly fast nightly build w/ manifold enabled by default

So yeah, the last stable build of OpenSCAD is over 4 years old as of this writing.

Nightly (Dev) builds of OpenSCAD have seen 100x speed improvements since that release, when enabling the Manifold backend (see this presentation).

If you can install a Dev build instead of the stable version, you should! (then, pass --backend=manifold if using in Command line, or switch the renderer from slow CGAL to Manifold in the UI settings if using the UI; see instructions here).

If you can't install the Dev build, well, you kinda can (for command-line use only, and if you have Docker): put the openscad script below in your PATH, and you're good to go (make sure it's executable w/ chmod +x path/to/openscad).

Oh, and on MacOS some projects that use OpenSCAD assume its binary is in /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD. You can just rename any existing app, then type:

mkdir -p /Applications/OpenSCAD.app/Contents/MacOS
ln -s path/to/openscad /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
#!/bin/bash
set -euo pipefail
declare -a DOCKER_ARGS=()
declare -a OPENSCAD_ARGS=()
# Transform CLI arguments so any file / folder paths are mounted in Docker (in read-only, except for the -o output file in read-write)
# Folders are mounted at the same path in the container as in the host, which is unorthodox but simpler to manage.
while [[ $# -gt 0 ]]; do
arg="$1"
shift
if [[ "$arg" == "-o" ]]; then
[[ $# -eq 0 ]] && { echo "Error: -o requires an argument" >&2; exit 1; }
touch "$1"
REAL_PATH=$(realpath "$1")
DOCKER_ARGS+=( -v "${REAL_PATH}:${REAL_PATH}:rw" )
OPENSCAD_ARGS+=( -o "$REAL_PATH" )
shift
elif [[ -f "$arg" ]]; then
REAL_PATH=$(realpath "$arg")
DOCKER_ARGS+=( -v "${REAL_PATH}:${REAL_PATH}:ro" )
OPENSCAD_ARGS+=( "$REAL_PATH" )
else
OPENSCAD_ARGS+=("$arg")
fi
done
# Mount git repo root if we're in a git repo
GIT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [[ -n "$GIT_ROOT" ]]; then
DOCKER_ARGS+=( -v "${GIT_ROOT}:${GIT_ROOT}:ro" )
fi
# Mount OPENSCADPATH, w/ platform dependent default
if [[ -z "${OPENSCADPATH:-}" ]]; then
case "$(uname -s)" in
Darwin)
OPENSCADPATH="$HOME/Documents/OpenSCAD/libraries"
;;
Windows_NT | CYGWIN_NT*)
# Cygwin or Windows WSL
OPENSCADPATH="$(cygpath -u "$HOME/Documents/OpenSCAD/libraries")"
;;
*)
OPENSCADPATH="$HOME/.local/share/OpenSCAD/libraries"
;;
esac
fi
DOCKER_ARGS+=( -e "OPENSCADPATH=${OPENSCADPATH}" -v "${OPENSCADPATH}:${OPENSCADPATH}:ro" )
docker run --rm -it \
-w "$(pwd)" \
"${DOCKER_ARGS[@]}" \
openscad/openscad:dev \
openscad "${OPENSCAD_ARGS[@]}" \
--backend="${OPENSCAD_BACKEND:-manifold}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment