diff --git a/build.sh b/build.sh
index d7f1e17..9d4506a 100755
--- a/build.sh
+++ b/build.sh
@@ -17,20 +17,19 @@ run () {
# 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
+ logfile=$basename.log
+ run openscad -o $basename "$@" temp-tower.scad 2>&1 | tee $logfile
+ rm -rf Metadata
mkdir -p Metadata
- custom=Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml
- (
- echo ''
- echo ''
- sed -n 's/ECHO: "CUSTOM##\(.*\)"/\1/p' $basename.log
- echo ''
- echo ''
- ) > $custom
+ cat $logfile | while IFS=# read _ _ custom type path text _; do
+ [ "$custom#$type" = "CUSTOM#3mf" ] || continue
+ echo $text >> $path
+ done
+
run zip $basename $custom
- rm $custom $basename.log
+ rm $custom $logfile
rmdir Metadata
}
diff --git a/temp-tower.scad b/temp-tower.scad
index ef47662..9cd31fe 100644
--- a/temp-tower.scad
+++ b/temp-tower.scad
@@ -84,35 +84,52 @@ module EngraveText(text) {
text(text, size=3.2, valign="center", font=Font);
}
-module Custom(text) {
- echo(str("CUSTOM##", text));
+// Ouptut special code to add to 3mf file
+module ZCodeWrite(text) {
+ echo(str(
+ "#",
+ "#CUSTOM",
+ "#3mf",
+ "#Metadata/Prusa_Slicer_custom_gcode_per_print_z.xml",
+ "#", text,
+ "##"
+ ));
}
-difference() {
- union() {
- cube([25, 5, PlateHeight]); // Floor plate
- for (tier = [0 : 1 : Tiers-1]) {
- z = PlateHeight + (5 * tier);
- temp = TempBase + (TempIncrease * tier);
- Custom(str(
- "
",
- ""
- ));
- translate([0, 0, z]) Tier(temp);
+module main() {
+ ZCodeWrite("");
+ ZCodeWrite("");
+ difference() {
+ union() {
+ cube([25, 5, PlateHeight]); // Floor plate
+ for (tier = [0 : 1 : Tiers-1]) {
+ z = PlateHeight + (5 * tier);
+ temp = TempBase + (TempIncrease * tier);
+ ZCodeWrite(str(
+ "
",
+ ""
+ ));
+ translate([0, 0, z]) Tier(temp);
+ }
+ }
+ if (FullTower) {
+ translate([25 - EngraveDepth, 2.5, 1+PlateHeight])
+ rotate([90, -90, 90])
+ EngraveText(SideText);
+ } else {
+ translate([4 + EngraveDepth, 2.5, 1+PlateHeight])
+ rotate([90, -90, -90])
+ EngraveText(SideText);
}
}
- if (FullTower) {
- translate([25 - EngraveDepth, 2.5, 1+PlateHeight])
- rotate([90, -90, 90])
- EngraveText(SideText);
- } else {
- translate([4 + EngraveDepth, 2.5, 1+PlateHeight])
- rotate([90, -90, -90])
- EngraveText(SideText);
- }
+ ZCodeWrite("");
+ ZCodeWrite("");
}
+
+main();
+