<# .SYNOPSIS Exports the Kazah Tender from the user's .blend to SourceArt\Kazah (FBX per part + manifest) and regenerates Source\TheDescent\Vehicles\KazahLayout.inl. Headless Blender; the .blend is never saved. .EXAMPLE powershell -NoProfile -ExecutionPolicy Bypass -File Tools\export_kazah.ps1 powershell -NoProfile -ExecutionPolicy Bypass -File Tools\export_kazah.ps1 -SubsurfLevel 1 # lighter hull Exit code 0 = PASS, 1 = FAIL. #> [CmdletBinding()] param( [string]$Blend = 'D:\HADAL - The Descent\models\Kazah-stern-cavity-fixedv4.blend', # Override the hull's subdivision level in memory (the file uses 2, about 880k triangles). Omit to keep it. [int]$SubsurfLevel = -1 ) $ErrorActionPreference = 'Stop' $ProjectRoot = Split-Path -Parent $PSScriptRoot $Blender = 'E:\Steam\steamapps\common\Blender\blender.exe' $Script = Join-Path $PSScriptRoot 'blender\export_kazah.py' $LogFile = Join-Path $ProjectRoot 'Saved\Logs\export_kazah_last.log' if (-not (Test-Path $Blender)) { Write-Host "EXPORT FAIL: Blender not found at $Blender"; exit 1 } if (-not (Test-Path $Blend)) { Write-Host "EXPORT FAIL: $Blend not found"; exit 1 } New-Item -ItemType Directory -Force -Path (Split-Path $LogFile) | Out-Null $before = Get-Item $Blend $sw = [System.Diagnostics.Stopwatch]::StartNew() $blArgs = @('-b', ('"' + $Blend + '"'), '--python-exit-code', '1', '--python', ('"' + $Script + '"'), '--') if ($SubsurfLevel -ge 0) { $blArgs += @('--subsurf-level', "$SubsurfLevel") } # Blender prints progress to stdout; keep all of it in the log file. cmd /c so stderr lines stay plain text. cmd.exe /c ('"' + $Blender + '" ' + ($blArgs -join ' ') + ' > "' + $LogFile + '" 2>&1') $exit = $LASTEXITCODE $sw.Stop() $lines = Get-Content $LogFile if ($VerbosePreference -eq 'Continue') { $lines | ForEach-Object { Write-Host $_ } } else { $lines | Where-Object { $_ -match '^\[export_kazah\]' } | ForEach-Object { Write-Host $_ } } $after = Get-Item $Blend if ($before.Length -ne $after.Length -or $before.LastWriteTimeUtc -ne $after.LastWriteTimeUtc) { Write-Host "EXPORT FAIL: the source .blend changed on disk. This must never happen." exit 1 } $secs = [math]::Round($sw.Elapsed.TotalSeconds, 1) if ($exit -eq 0) { Write-Host ("EXPORT PASS {0}s -> SourceArt\Kazah" -f $secs); exit 0 } Write-Host ("EXPORT FAIL exit={0} {1}s log={2}" -f $exit, $secs, $LogFile) exit 1