More general file creation

This commit is contained in:
Neale Pickett 2023-11-26 15:34:26 -07:00
parent 2d9aff43c1
commit 78ae418a35
2 changed files with 53 additions and 37 deletions

View File

@ -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 '<?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
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
}

View File

@ -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(
"<code print_z=\"", z, "\"",
" type=\"4\"",
" extruder=\"1\"",
" color=\"\"",
" extra=\"M104 S", temp, "\"",
" gcode=\"M104 S", temp, "\"/>",
""
));
translate([0, 0, z]) Tier(temp);
module main() {
ZCodeWrite("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
ZCodeWrite("<custom_gcodes_per_print_z>");
difference() {
union() {
cube([25, 5, PlateHeight]); // Floor plate
for (tier = [0 : 1 : Tiers-1]) {
z = PlateHeight + (5 * tier);
temp = TempBase + (TempIncrease * tier);
ZCodeWrite(str(
"<code print_z=\"", z, "\"",
" type=\"4\"",
" extruder=\"1\"",
" color=\"\"",
" extra=\"M104 S", temp, "\"",
" gcode=\"M104 S", temp, "\"/>",
""
));
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("<mode value=\"SingleExtruder\"/>");
ZCodeWrite("</custom_gcodes_per_print_z>");
}
main();