Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:savefile [2015/09/14]
developer:scriptsamples:savefile [2015/09/14] (current)
Line 1: Line 1:
 +====== Saving Files ======
 +> **Developer:​** //​[[developer:​rhinoscript|RhinoScript]]//​
 +> **Summary:​** //​Demonstrates how to save a file using RhinoScript.//​
  
 +===== Question =====
 +How can I save a file using RhinoScript?​
 +
 +===== Answer =====
 +You can save files by scripting either Rhino'​s **Save** or **SaveAs** command using RhinoScript'​s **Command** method.
 +
 +===== Example =====
 +
 +<code vb>
 +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
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer RhinoScript}}
developer/scriptsamples/savefile.txt ยท Last modified: 2015/09/14 (external edit)