51 lines
2.0 KiB
PowerShell
51 lines
2.0 KiB
PowerShell
|
|
<#
|
||
|
|
.SYNOPSIS
|
||
|
|
Installs (or updates) the TinqsBlenderBridge auto-start module.
|
||
|
|
|
||
|
|
.DESCRIPTION
|
||
|
|
Copies tools/blender_bridge/tinqs_blender_bridge.py (the server's source
|
||
|
|
of truth in this repo) into Blender's user scripts/startup/ folder.
|
||
|
|
Startup modules are imported at every Blender launch and their register()
|
||
|
|
is called, so the bridge auto-starts on port 19000 from the next launch
|
||
|
|
onward. Idempotent -- safe to re-run after editing the server source.
|
||
|
|
|
||
|
|
This does NOT start the bridge in an already-open Blender. For that, in
|
||
|
|
the open window: Scripting workspace > open the repo copy > Run Script.
|
||
|
|
|
||
|
|
.EXAMPLE
|
||
|
|
powershell -File tools\install_blender_bridge.ps1
|
||
|
|
#>
|
||
|
|
|
||
|
|
$ErrorActionPreference = "Stop"
|
||
|
|
|
||
|
|
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||
|
|
$SourceFile = Join-Path $RepoRoot "tools\blender_bridge\tinqs_blender_bridge.py"
|
||
|
|
$BlenderCfg = Join-Path $env:APPDATA "Blender Foundation\Blender"
|
||
|
|
|
||
|
|
if (-not (Test-Path $SourceFile)) {
|
||
|
|
Write-Error "Bridge source not found: $SourceFile"
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
$versions = Get-ChildItem -Directory $BlenderCfg | Where-Object { $_.Name -match '^\d+\.\d+$' }
|
||
|
|
if (-not $versions) {
|
||
|
|
Write-Error "No Blender version folders under $BlenderCfg -- has Blender been run at least once?"
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
foreach ($v in $versions) {
|
||
|
|
$startupDir = Join-Path $v.FullName "scripts\startup"
|
||
|
|
New-Item -ItemType Directory -Force -Path $startupDir | Out-Null
|
||
|
|
Copy-Item -Path $SourceFile -Destination $startupDir -Force
|
||
|
|
Write-Host "Installed to: $(Join-Path $startupDir 'tinqs_blender_bridge.py')" -ForegroundColor Cyan
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host ""
|
||
|
|
Write-Host "The bridge auto-starts (port 19000) on every FUTURE Blender launch." -ForegroundColor Yellow
|
||
|
|
Write-Host "For the currently open Blender: Scripting workspace > Open > " -ForegroundColor Yellow
|
||
|
|
Write-Host " $SourceFile" -ForegroundColor Yellow
|
||
|
|
Write-Host " then Run Script (the play button)." -ForegroundColor Yellow
|
||
|
|
Write-Host ""
|
||
|
|
Write-Host "Verify: python tools\blender_bridge.py --ping"
|
||
|
|
Write-Host "Log file once running: `$env:TEMP\tinqs_blender_bridge.log"
|