Site Tools

Saving Files

Developer: RhinoScript
Summary: Demonstrates how to save a file using RhinoScript.


How can I save a file using RhinoScript?


You can save files by scripting either Rhino's Save or SaveAs command using RhinoScript's Command method.


Option Explicit
Sub SaveRhinoFile
  ' Declare local variables
  Dim strFileName, strCommand
  ' Prompt the user for the name of the file to save  
  strFileName = Rhino.SaveFileName("Save", "Rhino 3D Models (*.3dm)|*.3dm||")
  If IsNull(strFileName) Then Exit Sub
  ' Since filenames can contain spaces, we need to
  ' surround the string with double-quote characters,
  ' or "", when scripting.    
  strFileName = Chr(34) & strFileName & Chr(34)
  ' Build the command script
  strCommand = "_-Save " & strFileName
  ' Script the save command
  Call Rhino.Command(strCommand, 0)
End Sub

developer/scriptsamples/savefile.txt ยท Last modified: 2020/08/14 (external edit)