I am trying to adapt a .rvb script to convert from IGES to 3DM files automatically, and I do need to set the name of the objects to be the same as the imported file name and I get stuck at:
Rhino.ObjectName arrObjects, Chr(34), 0
How I can name the objects as the input filename?
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’
’ BatchConvert_IGS_to_3DM script for Rhinoceros
’ Robert McNeel & Associates
’ www.rhino3d.com
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’Option Explicit
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’
’ BatchConvert_IGS_3DM
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’
Sub BatchConvert_IGS_3DM()’ Make sure RhinoScript does not reinitialize when opening models,
’ otherwise this script will only process one file.
Rhino.Command “_-Options _RhinoScript _Reinitialize=_No _Enter _Enter”, 0’ Allow the user to interactively pick a folder
Dim sFolder
sFolder = Rhino.BrowseForFolder(, “Select folder to process”, “Batch Convert IGS_to_3DM”)
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
ProcessFolder oFSO, oFolder’ Release the objects
Set oFolder = Nothing
Set oFSO = Nothing’ Close the last file processed
Rhino.DocumentModified False
Rhino.Command “_-New _None”, 0End Sub
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’
’ ProcessFolder
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’
Sub ProcessFolder(oFSO, oFolder)’ Process all .igs files in the selected folder
Dim oFile, strOpen, strSave
For Each oFile In oFolder.Files
If LCase(oFSO.GetExtensionName(oFile.Path)) = “igs” Then
strOpen = LCase(oFile.Path)
strSave = LCase(Replace(strOpen, “.igs”, “.3dm”, 1, -1, 1))
ProcessFile strOpen, strSave
End If
Next’ Comment out the following lines if you do not
’ want to recursively process the selected folder.
Dim oSubFolder
For Each oSubFolder In oFolder.SubFolders
ProcessFolder oFSO, oSubFolder
NextEnd Sub
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’
’ ProcessFile
‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’
Sub ProcessFile(strOpen, strSave)
Rhino.DocumentModified False
Rhino.Command "-Open " & Chr(34) & strOpen & Chr(34), 0
Rhino.Command "-Zoom _All Extents", 0
Rhino.Command "-SetActiveView Top", 0
Rhino.Command "-SetDisplayMode _Viewport=_All _Mode=Ghosted", 0
Rhino.Command "-Purge _BloackDefinitions=Yes _AnnotationStyles=Yes _Groups=Yes _HatchPatterns=Yes _Layers=Yes _Linetype=Yes _Materials=Yes _Textures=Yes Environments=Yes Bitmaps=Yes Enter", 0
Rhino.Command "-SelAll", 0
Rhino.ObjectName arrObjects, Chr(34), 0
Rhino.Command "-Join", 0
Rhino.RenameLayer “IGES level 0”, “Fittings”
Rhino.LayerColor “Fittings”, RGB(0, 255, 0)
Rhino.Command "-SaveAs Version=6 " & Chr(34) & strSave & Chr(34), 0
End Sub