Skip to content

Instantly share code, notes, and snippets.

@the-ress
Created September 2, 2022 18:25
Show Gist options
  • Save the-ress/5e098a5a604e876992871fa3519385e7 to your computer and use it in GitHub Desktop.
Save the-ress/5e098a5a604e876992871fa3519385e7 to your computer and use it in GitHub Desktop.
Prusa MK3S multicolor print without MMU
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dpn0.ps1" %*
$ErrorActionPreference = "Stop"
$filename = $args[0]
if (-not $filename) {
Write-Host "No filename argument"
exit 1
}
Write-Host "Reading file..."
$content = Get-Content $filename
Write-Host "Processing..."
$first = $true
$content = $content | % {
if ($_ -cmatch '^T(\d+)$') {
if ($first) {
$first = $false
Write-Host "Ignoring first tool change: $($Matches[0])"
return '' # Ignore the first one
}
else {
Write-Host "Replacing tool change: $($Matches[0])"
return "M600 ; change to color $($Matches[1])"
}
}
return $_
}
Write-Host "Saving file..."
$content | Set-Content $filename
Write-Host "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment