-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBatchOpenIges.rvb
74 lines (55 loc) · 2.08 KB
/
BatchOpenIges.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchOpenIges.rvb -- January 2005
' 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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchProcessFiles
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BatchProcessFiles()
' Allow the user to interactively pick a folder
Dim sFolder
sFolder = Rhino.BrowseForFolder( , "Select folder to process", "Batch Open IGES" )
If VarType( sFolder ) <> vbString 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 folder
RecurseFolder oFolder
' Release the objects
Set oFolder = Nothing
Set oFSO = Nothing
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RecurseFolder
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RecurseFolder( oFolder )
' Process each file in the folder
Dim oFile
For Each oFile In oFolder.Files
ProcessFile oFile.Path
Next
' Remark out the following lines if you do not want
' to recursively process the folder
' Process each subfolder in this folder
Dim oSubFolder
For Each oSubFolder In oFolder.SubFolders
RecurseFolder( oSubFolder )
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ProcessFile
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ProcessFile( sFile )
' Once we have gotten here, we have a valid file name.
' In this case, we are interested in just IGES files.
If (InStr(LCase(sFile), ".IGS") > 0) Or (InStr(LCase(sFile), ".IGES") > 0) Then
Rhino.Command "_-Open " & Chr(34) & sFile & Chr(34)
' TODO: Add functionality here
End If
End Sub