-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathBatchExtractThumbnails.rvb
57 lines (44 loc) · 1.87 KB
/
BatchExtractThumbnails.rvb
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchExtractThumbnails.rvb -- October 2008
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchExtractThumbnails
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BatchExtractThumbnails()
' Allow the user to interactively pick a folder
Dim sFolder : sFolder = Rhino.WorkingFolder
sFolder = Rhino.BrowseForFolder(sFolder, "Select folder to process", "Batch Extract Thumbnails" )
If IsNull(sFolder) Then Exit Sub
' Create a file system object
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
' Get a folder object based on the selected folder
Dim oFolder : Set oFolder = oFSO.GetFolder(sFolder)
' Process the entire folder
Call DoThumbnailExtraction(oFSO, oFolder)
' Done
Call Rhino.Print("Done!")
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DoThumbnailExtraction
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DoThumbnailExtraction(oFSO, oFolder)
' Process all 3dm files in the folder
Dim oFile, strOpen, strSave
For Each oFile In oFolder.Files
If LCase(oFSO.GetExtensionName(oFile.Path)) = "3dm" Then
strOpen = LCase(oFile.Path)
strSave = LCase(Replace(strOpen, ".3dm", ".jpg", 1, -1, 1))
Call Rhino.Print("Processing " & strOpen & "...")
Call Rhino.ExtractPreviewImage(strSave, strOpen)
End If
Next
' Un-comment the following if you want to recurse this folder
'Dim oSubFolder
'For Each oSubFolder In oFolder.SubFolders
' Call DoThumbnailExtraction(oFSO, oSubFolder)
'Next
End Sub