Skip to content

Instantly share code, notes, and snippets.

@thanhph111
Last active August 18, 2022 23:17
Show Gist options
  • Save thanhph111/99ba889a2ce180c9beffa8372e982249 to your computer and use it in GitHub Desktop.
Save thanhph111/99ba889a2ce180c9beffa8372e982249 to your computer and use it in GitHub Desktop.
PowerShell scripts for replacing annoying rendering status with animated one when rendering Blender using command-line #snippet
function Render-Blender {
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$InputFile,
[Parameter()]
[string]$OutputFile = "//Render_",
[Parameter(Mandatory = $true)]
[ValidateSet("BLENDER_EEVEE", "CYCLES")]
[string]$Engine = "BLENDER_EEVEE"
)
$InputFile = (Get-Item $InputFile).FullName
$CurrentLine = $Host.UI.RawUI.CursorPosition.Y
$ConsoleWidth = $Host.UI.RawUI.BufferSize.Width
$Before = $false
$Parameters = @(
"--background", $InputFile
"--render-output", $OutputFile
"--engine", $Engine
"--render-format", "PNG"
"--use-extension", 1
"--render-frame", 1
)
blender @Parameters | ForEach-Object {
if ($Before) {
$CurrentLine = $Host.UI.RawUI.CursorPosition.Y
$Count = [math]::Ceiling($Length / $ConsoleWidth)
for ($i = 1; $i -le $Count; $i++) {
[Console]::SetCursorPosition(0, ($CurrentLine - $i))
[Console]::Write("{0,-$ConsoleWidth}" -f " ")
}
[Console]::SetCursorPosition(0, ($CurrentLine - $Count))
}
if ($_.StartsWith("Fra") -and
!($_.EndsWith("Finished")) -and
!($_.EndsWith("Ve:0 Fa:0 La:0"))) {
$Before = $true
$Length = $_.Length
} else {
$Before = $false
}
Write-Output $_
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment