Summary: Demonstrates how to open 3DM files using RhinoScript.
Does RhinoScript have a method for opening a file? I found the OpenFileName method in the help file, but it only lets you select a file name. It does not open the file.
To open files using RhinoScript, you simply script Rhino's Open command using RhinoScript's Command method.
The following sample demonstrates how you can open 3DM files using RhinoScript.
Sub TestFileOpen() ' Local variable declarations Dim strFile ' Let the user pick a 3dm file. If the return value is null, ' then the user picked the "Cancel" button... strFile = Rhino.OpenFileName("Open", "Rhino 3D Models (*.3dm)|*.3dm|") If IsNull(strFile) Then Exit Sub ' To keep Rhino from displaying the dreaded ' "Save changes to <filename>" dialog, we can fool it ' into thinking that the document was never modified ' by doing the following. Call Rhino.DocumentModified(False) ' If the picked a file that has a space character in its name, ' or resides in a folder that has a space character, then we ' need to surround the file string in double-quotes so Rhino's ' command line parser will interpret the string correctly. strFile = Chr(34) & strFile & Chr(34) ' Now we can simply script Rhino's Open command to open the file. Call Rhino.Command("_-Open " & strFile, 0) End Sub