Site Tools


Scripting with Persistent Settings

RhinoScript

Summary: How to use private variables for persistent settings.

It can be annoying to enter the same custom parameter each time you run a script. The following script demonstrates how to use a private variable to store a parameter during a Rhino session.

If your script should remember the settings from the last session, then you have to use the RhinoScript methods SaveSettings and GetSettings to access a separate *.ini file.


JessMaertterer

http://www.rhino3.de/

Example to demonstrate persistent parameters with private variables

 ' How to script with persisting settings
 ' Jess Maertterer - 20.12.2004
 Option Explicit
 Private dblLength
 
 If IsEmpty(dblLength) Then
   dblLength = 2.00
 End If
 
 '/////////////////////////////////////////////////////////////
 Sub Extend_Curve_Length_Persist
   Dim arrCurves, strCurve, dblResult
   arrCurves = Rhino.GetObjects("Select curves to extend", 4)
   If Not IsNull(arrCurves) Then
     dblResult = Rhino.GetReal("Length to extend", dblLength,0.00)
     If Not IsNull(dblResult) Then
       dblLength = dblResult
       For Each strCurve in arrCurves
         Rhino.ExtendCurveLength strCurve, 2, 2, dblLength
       Next
     End If
   End If
 End Sub
developer/scriptsamples/persistentsettings.txt ยท Last modified: 2010/01/26 (external edit)