Hi everyone, I’m stuck with this problem in rhinoscript.
I need to import some stl files into rhino and put each on a layer with the name o the folder they are in.
I have a main folder with subfoldes with stl files in them.
This is what I have so far:
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)
' Release the objects
Set objFolder = Nothing
Set objFSO = Nothing
End Sub
Sub RecurseFolder(objFolder)
Dim objFile, oSubFolder
' Process each file in the folder
For Each objFile In objFolder.Files
Call ProcessFolder(objFSO,objFolder)
Next
'Process Each subfolder In this folder
For Each oSubFolder In objFolder.SubFolders
Call RecurseFolder(oSubFolder)
Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ProcessFile
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ProcessFolder(objFSO,objFolder)
' Import all files in the selecte subfolder
Dim objFile,strOpen,arrLCO,strSubFolder
For Each objFile In objFolder.Files
strOpen = LCase(objFile.Path)
Call Rhino.Command ("_NoEcho _-Import "&chr(34)&strOpen&chr(34)&" _Enter")
arrLCO=Rhino.LastCreatedObjects(False)
strSubFolder = oSubFolder.Name
rhino.AddLayer(strSubFolder)
Rhino.ObjectLayer arrLCO,strSubFolder
Next
It works and imports every STL from each subfolder.
Where I’m stuck is to get the Subfolder name to create a layer.
Can someone give me a hand in this.
Thanks everyone