-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathBatchRender.vbs
77 lines (67 loc) · 2.05 KB
/
BatchRender.vbs
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
Option Explicit
Call BatchRender
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchRender
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BatchRender
Dim oRhino, oRhinoScript, nCount
Dim oFSO, oFolder, oFile
Dim sFolder, sFile, sBitmap
sFolder = "C:\Test"
WScript.Echo "Creating Rhino object..."
On Error Resume Next
Set oRhino = CreateObject("Rhino.Application")
If (Err.Number <> 0) Then
WScript.Echo "Failed to create Rhino object."
Exit Sub
Else
WScript.Echo "Rhino object created."
End If
WScript.Echo "Retrieving RhinoScript object..."
nCount = 0
Do While (nCount < 10)
On Error Resume Next
Set oRhinoScript = oRhino.GetScriptObject
If Err.Number <> 0 Then
Err.Clear
WScript.Sleep 500
nCount = nCount + 1
Else
Exit Do
End If
Loop
If (oRhinoScript Is Nothing) Then
WScript.Echo "Failed to retrieve RhinoScript object."
Set oRhino = Nothing
Exit Sub
Else
WScript.Echo "RhinoScript object retrieved."
End If
WScript.Echo "Creating file system object."
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sFolder)
For Each oFile In oFolder.Files
sFile = oFile.Path
If (InStr(LCase(sFile), ".3dm") > 0) Then
sBitmap = Replace(sFile, ".3dm", ".jpg", 1, -1, 1)
WScript.Echo "Processing " & sFile & "..."
oRhinoScript.DocumentModified = False
WScript.Echo " Opening"
oRhinoScript.Command "_-Open " & Chr(34) & sFile & Chr(34)
WScript.Echo " Rendering"
oRhinoScript.Command "_-Render"
WScript.Echo " Saving"
oRhinoScript.Command "_-SaveRenderWindowAs " & Chr(34) & sBitmap & Chr(34)
WScript.Echo " Closing render window"
oRhinoScript.Command "_-CloseRenderWindow"
oRhinoScript.DocumentModified = False
End If
Next
WScript.Echo "Cleaning up..."
Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
Set oRhinoScript = Nothing
Set oRhino = Nothing
WScript.Echo "Done!"
End Sub