Hi everyone, I just finished a script to import multiple files.
It was all working fine. I shut down rhino and started it again and now the script crashes Rhino.
I have no Ideia Way, I can’t see any mistakes but it has to be something.
Can anyone take a look please.
'Script written by FVA
'Script version 24 July 2013
Option Explicit
Private strOldFolder
If isEmpty(strOldFolder) Then
strOldFolder = Rhino.WorkingFolder
End If
Call BatchImportGen
Sub BatchImportGen()
' Allow the user to interactively pick a folder
Dim strFolder
strFolder = Rhino.BrowseForFolder(strOldFolder, "Select folder to process", "Batch Import")
If VarType(strFolder) <> vbString Then
Exit Sub
Else strOldFolder = strFolder
End If
' Create a file system object
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Get a folder object based on the selected folder
Dim objFolder
Set objFolder = objFSO.GetFolder(strFolder)
' Process the folder
Call RecurseFolder(objFolder,objFSO)
' Release the objects
Set objFolder = Nothing
Set objFSO = Nothing
End Sub
Sub RecurseFolder(objFolder,objFSO)
Dim objFile, oSubFolder
' Process each file in the folder
For Each objFile In objFolder.Files
Call ProcessFile(objFSO,objFolder,oSubFolder)
Next
'Process Each subfolder In this folder
For Each oSubFolder In objFolder.SubFolders
Call RecurseFolder(objFolder,objFSO)
Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ProcessFile
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ProcessFile(objFSO,objFolder,oSubFolder)
' Import all files in the selecte subfolder
Dim objFile,strOpen,arrLCO,strSubFolder, sail
For Each objFile In objFolder.Files
strOpen = LCase(objFile.Path)
Call Rhino.Command ("_NoEcho _-Import "&chr(34)&strOpen&chr(34)&" _Enter")
arrLCO=Rhino.LastCreatedObjects()
strSubFolder = objFolder.Name
rhino.AddLayer(strSubFolder)
Rhino.ObjectLayer arrLCO,strSubFolder
Next
End Sub