Created
September 2, 2022 18:25
-
-
Save the-ress/5e098a5a604e876992871fa3519385e7 to your computer and use it in GitHub Desktop.
Prusa MK3S multicolor print without MMU
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
@echo off | |
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dpn0.ps1" %* |
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
$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