-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathBatchRemovePlugInData.rvb
71 lines (59 loc) · 2.19 KB
/
BatchRemovePlugInData.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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchRemovePlugInData.rvb -- November 2017
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 5 or greater.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BatchRemovePlugInData
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BatchRemovePlugInData
If (Rhino.ExeVersion < 5) Then
Call Rhino.Print("This script requires Rhino 5 or greater.")
Exit Sub
End If
Dim sFolder : sFolder = Rhino.WorkingFolder
sFolder = Rhino.BrowseForFolder(sFolder, "Select folder to process", "Batch Remove Plug-in Data")
If IsNull(sFolder) Then Exit Sub
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oFolder : Set oFolder = oFSO.GetFolder(sFolder)
Call RemovePlugInData(oFSO, oFolder)
Call Rhino.DocumentModified(False)
Call Rhino.Command("_-New _None", 0)
Call Rhino.Print("Done!")
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RemovePlugInData
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RemovePlugInData(oFSO, oFolder)
Dim oFile, strOpen, arrInfo, strVer
For Each oFile In oFolder.Files
If LCase(oFSO.GetExtensionName(oFile.Path)) = "3dm" Then
strOpen = LCase(oFile.Path)
arrInfo = Rhino.DocumentInfo(strOpen)
If IsArray(arrInfo) Then
If arrInfo(1) = 2 Then
strVer = "_Version=2"
ElseIf arrInfo(1) = 3 Then
strVer = "_Version=3"
ElseIf arrInfo(1) = 4 Then
strVer = "_Version=4"
ElseIf arrInfo(1) = 50 Then
strVer = "_Version=5"
Else
strVer = "_Version=6"
End If
Call Rhino.DocumentModified(False)
Call Rhino.Command("_-Open " & Chr(34) & strOpen & Chr(34), False)
Call Rhino.Command("_-Save " & strVer & " _SavePlugInData=_No _Enter", False)
End If
End If
Next
' *** NOTE ***
' Uncomment the following if you want to recurse this folder.
'Dim oSubFolder
'For Each oSubFolder In oFolder.SubFolders
' Call RemovePlugInData(oFSO, oSubFolder)
'Next
End Sub