Compare commits
2 Commits
2d9aff43c1
...
2f6156c0c2
Author | SHA1 | Date |
---|---|---|
Neale Pickett | 2f6156c0c2 | |
Neale Pickett | 78ae418a35 |
|
@ -0,0 +1,16 @@
|
||||||
|
PARAMSETS != cat params.json | jq -r '.parameterSets | keys[] | select(length > 0)'
|
||||||
|
OUTPUTS = $(PARAMSETS:%=%.3mf)
|
||||||
|
|
||||||
|
all: $(OUTPUTS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OUTPUTS) *.bare.3mf *.log
|
||||||
|
|
||||||
|
targets:
|
||||||
|
@for i in $(PARAMSETS); do echo $$i.3mf; done
|
||||||
|
|
||||||
|
%.bare.3mf %.log: temp-tower.scad params.json
|
||||||
|
openscad -o $*.bare.3mf -P $* -p params.json temp-tower.scad 2>$*.log
|
||||||
|
|
||||||
|
%.3mf: %.bare.3mf %.log postprocess.sh
|
||||||
|
./postprocess.sh $@ $*.bare.3mf $*.log
|
31
README.md
31
README.md
|
@ -4,14 +4,31 @@ A Tiny Temperature Tower
|
||||||
This is a tiny temperature tower.
|
This is a tiny temperature tower.
|
||||||
I made it because I suspected my printer's hotend thermistor was reporting too cold.
|
I made it because I suspected my printer's hotend thermistor was reporting too cold.
|
||||||
|
|
||||||
`build.sh` generates `.3mf` files
|
(I think I was right.)
|
||||||
with extra code to make PrusaSlicer change temperatures automatically.
|
|
||||||
|
|
||||||
Defining A New Model
|
|
||||||
======================
|
|
||||||
|
|
||||||
You can add a new set of model parameters to `params.json`.
|
Building
|
||||||
|
----------
|
||||||
|
|
||||||
|
This uses make(1).
|
||||||
|
If you've never used make(1) before,
|
||||||
|
here's a quick introduction:
|
||||||
|
|
||||||
|
make all # Build everything
|
||||||
|
make clean # Remove build files
|
||||||
|
make targets # List everything you can build
|
||||||
|
|
||||||
|
|
||||||
|
Building A New Model
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
You can add a new set of model parameters to [params.json](params.json).
|
||||||
|
|
||||||
Let's say you named your new parameters `my-new-parameters`.
|
Let's say you named your new parameters `my-new-parameters`.
|
||||||
`build.sh my-new-parameters` will generate `my-new-parameters.3mf`,
|
|
||||||
with PrusaSlicer temperature changes and ponies and everything.
|
make my-new-parameters.3mf # Build only your model
|
||||||
|
|
||||||
|
The resulting 3mf file will have
|
||||||
|
temperature changes for PrusaSlicer
|
||||||
|
and ponies
|
||||||
|
and everything!
|
||||||
|
|
70
build.sh
70
build.sh
|
@ -1,70 +0,0 @@
|
||||||
#! /bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# paramsets contains the location of the OpenSCAD parameter sets.
|
|
||||||
# see https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Customizer#Saving_Parameters_value_in_JSON_file
|
|
||||||
paramsets=params.json
|
|
||||||
|
|
||||||
# run executes a program after printing the commandline to stdout.
|
|
||||||
run () {
|
|
||||||
echo "=== $*"
|
|
||||||
"$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# render turns OpenSCAD echo into 3mf temperature changes.
|
|
||||||
#
|
|
||||||
# It does this by kludging together a PrusaSlicer-specific Metadata file.
|
|
||||||
render () {
|
|
||||||
basename=$1; shift
|
|
||||||
run openscad -o $basename "$@" temp-tower.scad 2>&1 | tee $basename.log
|
|
||||||
|
|
||||||
mkdir -p Metadata
|
|
||||||
custom=Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml
|
|
||||||
(
|
|
||||||
echo '<?xml version="1.0" encoding="utf-8"?>'
|
|
||||||
echo '<custom_gcodes_per_print_z>'
|
|
||||||
sed -n 's/ECHO: "CUSTOM##\(.*\)"/\1/p' $basename.log
|
|
||||||
echo '<mode value="SingleExtruder"/>'
|
|
||||||
echo '</custom_gcodes_per_print_z>'
|
|
||||||
) > $custom
|
|
||||||
run zip $basename $custom
|
|
||||||
|
|
||||||
rm $custom $basename.log
|
|
||||||
rmdir Metadata
|
|
||||||
}
|
|
||||||
|
|
||||||
# paramsets lists all defined parameter sets, one per line.
|
|
||||||
paramsets () {
|
|
||||||
cat $paramsets | jq -r '.parameterSets | keys[] | select(length > 0)'
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
-h|-help|--help)
|
|
||||||
cat <<EOD
|
|
||||||
Usage: $0 [-paramsets] [PARAMSET ...]
|
|
||||||
|
|
||||||
Generates .3mf files with temperature changes
|
|
||||||
for each given parameter set.
|
|
||||||
|
|
||||||
Parameter sets are specified in $paramsets.
|
|
||||||
|
|
||||||
-paramsets List all defined parameter sets, and exit.
|
|
||||||
EOD
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
-p*|--p*)
|
|
||||||
paramsets
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
"")
|
|
||||||
paramsets | while read paramset; do
|
|
||||||
render $paramset.3mf -P $paramset -p $paramsets
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
for paramset in "$@"; do
|
|
||||||
render $paramset.3mf -P $paramset -p $paramsets
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
## Postprocess a 3mf file, adding in anything in the log
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
outfile=$(realpath $1)
|
||||||
|
infile=$(realpath $2)
|
||||||
|
logfile=$(realpath $3)
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d --tmpdir 3mf.XXXXXXXXXX)
|
||||||
|
trap "rm -rf $tmpdir" EXIT
|
||||||
|
|
||||||
|
(cd $tmpdir && unzip $infile)
|
||||||
|
|
||||||
|
cat $logfile | while IFS=# read _ _ custom type path text _; do
|
||||||
|
[ "$custom#$type" = "CUSTOM#3mf" ] || continue
|
||||||
|
basepath=$(dirname $path)
|
||||||
|
mkdir -p $tmpdir/$basepath
|
||||||
|
echo $text >> $tmpdir/$path
|
||||||
|
done
|
||||||
|
|
||||||
|
(cd $tmpdir && zip -r $outfile .)
|
|
@ -84,17 +84,28 @@ module EngraveText(text) {
|
||||||
text(text, size=3.2, valign="center", font=Font);
|
text(text, size=3.2, valign="center", font=Font);
|
||||||
}
|
}
|
||||||
|
|
||||||
module Custom(text) {
|
// Ouptut special code to add to 3mf file
|
||||||
echo(str("CUSTOM##", text));
|
module ZCodeWrite(text) {
|
||||||
|
echo(str(
|
||||||
|
"#",
|
||||||
|
"#CUSTOM",
|
||||||
|
"#3mf",
|
||||||
|
"#Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml",
|
||||||
|
"#", text,
|
||||||
|
"##"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
difference() {
|
module main() {
|
||||||
|
ZCodeWrite("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
|
ZCodeWrite("<custom_gcodes_per_print_z>");
|
||||||
|
difference() {
|
||||||
union() {
|
union() {
|
||||||
cube([25, 5, PlateHeight]); // Floor plate
|
cube([25, 5, PlateHeight]); // Floor plate
|
||||||
for (tier = [0 : 1 : Tiers-1]) {
|
for (tier = [0 : 1 : Tiers-1]) {
|
||||||
z = PlateHeight + (5 * tier);
|
z = PlateHeight + (5 * tier);
|
||||||
temp = TempBase + (TempIncrease * tier);
|
temp = TempBase + (TempIncrease * tier);
|
||||||
Custom(str(
|
ZCodeWrite(str(
|
||||||
"<code print_z=\"", z, "\"",
|
"<code print_z=\"", z, "\"",
|
||||||
" type=\"4\"",
|
" type=\"4\"",
|
||||||
" extruder=\"1\"",
|
" extruder=\"1\"",
|
||||||
|
@ -115,4 +126,10 @@ difference() {
|
||||||
rotate([90, -90, -90])
|
rotate([90, -90, -90])
|
||||||
EngraveText(SideText);
|
EngraveText(SideText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ZCodeWrite("<mode value=\"SingleExtruder\"/>");
|
||||||
|
ZCodeWrite("</custom_gcodes_per_print_z>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue