Last active
June 19, 2016 21:41
-
-
Save dmerand/43250c688d73f6b589ae7ed13bb1ce7d to your computer and use it in GitHub Desktop.
Insert a pause into a GCODE <<file>> at <<layer number>>, matching layers against an optional <<regex>>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
#---------------------------------------------------------# | |
# gcode_pause | |
# Donald L. Merand | |
# ---------------- | |
# Given (1) a file, (2) a layer number, and an optional | |
# (3) regular expression matching layer change, add a | |
# pause command (defaults to "M226" but changeable) to | |
# the GCODE. | |
#---------------------------------------------------------# | |
# if your printer firmware does something different to pause, eg M0, | |
# vvvvvv change this | |
PAUSE_CMD="M226" | |
# "parse" input params | |
FILENAME="$1" | |
shift | |
LAYER="$1" | |
shift | |
if [ "$1" ]; then | |
REGEX="$1" | |
else | |
# if you don't use Simplify3D, you might want to change... | |
# vvvvvvvvvvvvvvvvv default layer change code in Simplify3D. | |
REGEX="; layer ${LAYER}," | |
fi | |
# test for legit params | |
if [ -z "${FILENAME}" -o -z "${LAYER}" ]; then | |
echo "USAGE: gcode_pause <<FILENAME>> <<LAYER_NUMBER_TO_PAUSE>> {LAYER_REGEX}" | |
exit 1 | |
fi | |
# otherwise insert layer pause code | |
cat "${FILENAME}" | | |
awk "/${REGEX}/{print \"; USER-ADDED PAUSE\n${PAUSE_CMD}\"}{print \$0}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment