-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
87 lines (70 loc) · 2.41 KB
/
Copy pathrun.ps1
File metadata and controls
87 lines (70 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Param(
[switch]$Rename,
[switch]$ShowCommands,
[switch]$ShowBlender,
[String]$SceneFolder,
[String]$OrganName
)
if($ShowCommands) {
Set-PSDebug -Trace 1
}
Function Select-Folder($Description) {
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
[System.Windows.Forms.FolderBrowserDialog] $dialog = New-Object System.Windows.Forms.FolderBrowserDialog
$dialog.Description = $Description
if ($dialog.ShowDialog() -eq "OK") {
return $dialog.SelectedPath
}
else {
Write-Error "Operation cancelled by user."
return $null
}
}
# Get the scene folder
if([string]::IsNullOrEmpty($SceneFolder)) {
$SceneFolder = Select-Folder -Description "Select unzipped model folder";
if([string]::IsNullOrEmpty($SceneFolder)) {
Write-Error "Please select a valid scene folder"
exit
}
}
# Get the organ's name
if([string]::IsNullOrEmpty($OrganName)) {
$OrganName = Read-Host "What does this scene model? (e.g. Brain, Heart, ect)"
if([string]::IsNullOrEmpty($OrganName)) {
Write-Error "Please enter a valid organ name"
exit
}
}
$modelsFolder = "$SceneFolder\models"
if($Rename) {
# Add the correct name to each model file
. ((Split-Path $MyInvocation.MyCommand.Path) + "\parseNameAndFile.ps1")
$modelsFolder = "$SceneFolder\models\namedModels"
AddNamesToModels -Folder $SceneFolder -NamedModelFolder $modelsFolder
}
# Ensure the blender path is set properly
if(!$Env:BlenderLocation -or !(Test-Path $Env:BlenderLocation)) {
Write-Warning "This script requires Blender. Please show me where it lives"
$blenderFolder = Select-Folder -Description "Please select folder containing blender.exe (e.g. ...\Blender Foundation\Blender\)";
if([string]::IsNullOrEmpty($blenderFolder)) {
Write-Error "Please select a valid folder"
exit
}
if(!(Test-Path $blenderFolder)) {
Write-Error "Blender folder invalid"
exit
}
$Env:BlenderLocation = $blenderFolder
}
# Start Blender in the background
# And run the script that loads all objects and places them at origin
$backgroundFlag = "";
if(!$ShowBlender) {
$backgroundFlag = "--background"
}
Start-Process -FilePath "$Env:BlenderLocation\blender.exe" -ArgumentList "$backgroundFlag --python centerObjectsInBlender.py -- --folder `"$modelsFolder`" --newModelName `"$OrganName`""
Start $modelsFolder
if($ShowCommands) {
Set-PSDebug -Trace 0
}