$ErrorActionPreference = 'Stop' $Host.UI.RawUI.WindowTitle = 'Motor-CAD Central Mag Arc Scan 90-110 EDeg' Set-Location -LiteralPath $PSScriptRoot $safeDir = $PSScriptRoot.Replace('\', '/') $null = git -c "safe.directory=$safeDir" rev-parse --verify HEAD 2>$null if ($LASTEXITCODE -ne 0) { throw 'No Git commit exists. Commit the scripts before running.' } $trackedChanges = git -c "safe.directory=$safeDir" status --porcelain --untracked-files=no if ($trackedChanges) { throw 'Tracked files have uncommitted changes. Commit them before running.' } $commit = git -c "safe.directory=$safeDir" rev-parse --short HEAD $logPath = Join-Path $PSScriptRoot 'results\central_mag_arc_console.log' New-Item -ItemType Directory -Force -Path (Split-Path -Parent $logPath) | Out-Null Write-Host 'Starting a separate, visible Motor-CAD instance.' -ForegroundColor Cyan Write-Host "Committed version: $commit" -ForegroundColor Cyan Write-Host 'Range 90-110 EDeg, step 1, 21 points; model defaults: 30 points and 840 airgap mesh.' -ForegroundColor Cyan Write-Host "Progress log: $logPath" -ForegroundColor Cyan $pythonExe = 'C:\Users\zhang\AppData\Local\Microsoft\WindowsApps\python.exe' & $pythonExe -u .\scan_central_mag_arc.py ` --start 90 --stop 110 --step 1 ` --torque-points 0 --airgap-mesh 0 ` --new-instance --no-resume 2>&1 | Tee-Object -FilePath $logPath Write-Host '' Write-Host 'The scan process has ended. This window remains open for review.' -ForegroundColor Green