Loading Scripts

Scripts can be loaded into RhinoScript by either dragging a script file onto Rhino's main window, or by running the LoadScript command. Both methods are used load script files from disk into the memory of the VBScript engine.  The LoadScript command can be accessed from either Rhino's Tools menu, or by entering "LoadScript" on Rhino's command line.

 

loadscript.jpg

LoadScript options and operation

Load

Loads the selected script file into the memory of the VBScript engine.

Close

Closes the dialog box.

Add

Adds one or more script files to the list of available script files.  The default file extension for RhinoScript-specific VBScript files is " RVB".

Remove

Removes one or more script files from the list of available script files.

Edit

Loads the selected script file into the default script file editor.  See Scripting Options for details on assigning a default script file editor.

Help

Displays online help for this topic.

Save list

If checked, the list of available script files will be saved between sessions.

 

If the loaded script file contains only VBScript subroutines or function definitions, then the script code is not run, but is parsed for syntax errors and loaded into the memory of the VBScript interpreter so it can be recalled either by the user, by running the RunScript command, or by other VBScript functions or subroutines at a later time.  This is an excellent way of loading common functions used by many different subroutines or to load large scripts that might be time consuming to load every time you want to run a script.

If the loaded script file contains VBScript script code outside of the scope of a subroutine or function definition, then the script code is parsed, interpreted, and executed immediately.  This is useful when defining global variables, or if you just want a block of code to run when the script file is loaded.

Scripting the LoadScript command

As is the case with most Rhino command, the LoadScript command can be scripted, thus bypassing the interactive dialog box.  To script the LoadScript command, simply precede the command name with a hyphen when entering the command on Rhino's command line.  For example:

-LoadScript

After entering the command, you will be prompted to enter the name of the script file to load.  Simply enter the full path to the script file.  Use double-quote characters to support long file names, or paths that contain white spaces.  If you do not enter the full path, the LoadScript command will search for the script file in the following locations:

1.  The current model's folder.

2.  Every folder listed in Rhino's user-defined search path. (Use the Options command (Files page) to either view or modify this path.)

3. All Rhino system folders.

4. The Rhino executable folder.

Assigning the LoadScript command to a button.

The LoadScript command can also be assigned to a Rhino toolbar button.

 

loadscriptbutton.jpg